javascript - Setting specific location as center of map on reload Java script API -


i set google map load @ medina, oh. did find information map center loading specific location gave me example of chicago. i'm new java script please bare me.

below code change var map = var medina doesn't work. can please tell me why , how can set centered on medina, oh on page load?

    function initialize() {       var mapoptions = {         zoom: 13,         center: new google.maps.latlng(40.7809919,-73.9665273)       };        var map = new google.maps.map(document.getelementbyid('map-canvas'),           mapoptions);     }      function loadscript() {       var script = document.createelement('script');       script.type = 'text/javascript';       script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +           'callback=initialize';       document.body.appendchild(script);     }      window.onload = loadscript; 

as peter said, latitude , longitude coordinates need changed match desire center of map be.

the line:

center: new google.maps.latlng(40.7809919,-73.9665273) 

specifies center of map, latitude, longitude respectively.

if desire center of map @ latitude 30 , longitude -80, change line to

center: new google.maps.latlng(30.0000000,-80.0000000) 

this , good, desired center @ medina, ohio. locate geographical coordinates place, can use google maps, product customizing.

if navigate maps.google.com, can search 'medina, ohio.' bring view of city on map. if right click on location on map, , select 'what's here?' can see geographical coordinates place.

i selected point in center of medina , got latitude 41.1378070 , longitude -81.8641530. know coordinates, have change aforementioned line to:

center: new google.maps.latlng(41.1378070,-81.8641530) 

if desire, can select point on map customize coordinates map. if have questions, let me know!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -