Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps: Setting a new centre point using a menu
    text
    copied!<p>I'm pretty new to Google Maps. What I'm trying to do is set up a map which will center to points when an HTML menu is clicked.</p> <p>Am I right in saying I don't need an event listener if the control is outside the map?</p> <p>This is my code from the head section: ` function init() { var myLatlng = new google.maps.LatLng(53.53562,-1.05642); var myOptions = { zoom: 8, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } //draw the map var map = new google.maps.Map(document.getElementById("map"), myOptions);</p> <pre><code> //set up the marker var marker = new google.maps.Marker({ position: myLatlng, map: map, }); } function resetMap(lat,long) { var latlong = lat+","+long; var newPos = new google.maps.LatLng(latlong)({ setCenter: latlong, map: map, zoom:15, }) //add a marker var marker = new google.maps.Marker({ position: myLatlng, map: map, title:"New marker", }) } &lt;/script&gt;` </code></pre> <p>and the HTML goes like so:</p> <pre><code>&lt;body onLoad="init()"&gt; &lt;div id="selecter"&gt; &lt;select&gt; &lt;option onClick="resetMap(53.39433,-1.25754);"&gt;Thurcroft&lt;/option&gt; &lt;option onClick="resetMap(53.41615,-1.27833);"&gt;Wickersley&lt;/option&gt; &lt;option onClick="resetMap(53.47929,-1.14828);"&gt;M18/A1&lt;/option&gt; &lt;option onClick="resetMap(53.47802,-1.06633);"&gt;Rossington&lt;/option&gt; &lt;option onClick="resetMap(53.53562,-1.05642);"&gt;Armthorpe&lt;/option&gt; &lt;option onClick="resetMap(53.5914,-0.98797);"&gt;J5 M180&lt;/option&gt; &lt;option onClick="resetMap(53.61159,-0.96308);"&gt;Thorne&lt;/option&gt; &lt;option onClick="resetMap(53.62769,-0.95181);"&gt;Moorends&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div id="map"&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>...But nothing happens when the menu is accessed. Can anyone point me in the right direction - all suggestions appreciated ta!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload