Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps PanTo OnClick
    primarykey
    data
    text
    <p>I am trying to panTo an area on a map on click. The script is not working and page reloading. Perhaps someone can see the problem.</p> <p>My function</p> <pre><code>function clickroute(lati,long) { map = google.maps.Map(document.getElementById("map_canvas")); map.panTo(lati,long) } </code></pre> <p>And the rest</p> <pre><code>var directionDisplay; var directionsService = new google.maps.DirectionsService(); var map; function initialize() { geocoder = new google.maps.Geocoder(); directionsDisplay = new google.maps.DirectionsRenderer(); var chicago = new google.maps.LatLng(41.850033, -87.6500523); var myOptions = { zoom:10, mapTypeId: google.maps.MapTypeId.ROADMAP, center: chicago } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var address = 'virginia water'; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } }); directionsDisplay.setMap(map); } function calcRoute() { var start = document.getElementById("start").value; var end = document.getElementById("end").value; var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } </code></pre> <p>And my event</p> <pre><code>&lt;a href="" onclick="clickroute(51.433373, -0.712251)"&gt;test&lt;/a&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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