How to make the content of the map to switch to another location -


i use google maps javascript api, want map navigate location on map after initialize.

map = new google.maps.map (mapdiv, mapoptions); //in response user request navigate location. function goto (lat, lng) {   map.setcenter (new google.maps.latlng (lat, lng));   map.setzoom (13); } 

however, in case map display blank, click on operating controls unresponsive.

i tested code , works me... maybe rest of code wrong.
compare, here full working example. hope helps!

<!doctype html> <html>     <head>           <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=&sensor=false"></script>         <script type="text/javascript">              var map;              function initialize() {                 var mapoptions = {                     center: new google.maps.latlng(0, 0),                     zoom: 2,                     maptypeid: google.maps.maptypeid.roadmap                 };                 map = new google.maps.map(document.getelementbyid("map_canvas"), mapoptions);             }              function goto(lat, lng) {                 map.setcenter(new google.maps.latlng(lat, lng));                 map.setzoom(13);             }              function button_click() {                 //palo alto                 goto(37.429167, -122.138056);             }         </script>     </head>     <body onload="initialize()">         <div>         <input type="button" value="move" onclick="button_click()"/>         </div>         <div id="map_canvas" style="width: 100%; height: 500px"></div>       </body> </html> 

Comments