c# - Google Maps javascript code-behind visual studio -


i have javascript code in c# file code-behind:

  string markers = @"var address = '" + txtlocal.text + @"';   geocoder.geocode( { 'address': address}, function(results, status) {   map.setcenter(results[0].geometry.location);   var marker = new google.maps.marker({       map: map,         title: address,       position: results[0].geometry.location   }); 

});" ;

 literal1.text = @"  <script type='text/javascript'>  function initialize() {     geocoder = new google.maps.geocoder();     var mapoptions = { zoom: 15,    maptypeid: google.maps.maptypeid.hybrid  };     var map = new google.maps.map(document.getelementbyid('map_canvas'), mapoptions);"         + markers + @"     }  </script>"; 

i have piece of code in .aspx file:

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=aizasybf-_ruujxittvou3e0swutod8lu3bzkpi"></script>      <script src="http://code.jquery.com/jquery-2.1.4.min.js"type="text/javascript"></script>       <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=geometry,visualization&sensor=false"></script>    <script type="text/javascript">           $(function () {          initialize();         });  </script>          <asp:literal id="literal1" runat="server"></asp:literal>         <div id="map_canvas" style="width: 500px; height: 300px" /> 

i made few changes , it's working.

i think should use mymap in markers , not map-canvas eg:

 @"map: mymap });"; 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -