Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps geocoder not working properly
    primarykey
    data
    text
    <p>When the user drags a marker on the map I'm having trouble getting the location. The code works fine if the user clicks on the map and places a marker but not if it's dragged. Im not quite sure why its not working? Any help would be apprieciated. Heres my code</p> <pre><code>function initialize() { var latLng = new google.maps.LatLng(53.34235267846957, -6.264953253906242); map = new google.maps.Map(document.getElementById('map-canvas'), { zoom: 7, center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP }); marker = new google.maps.Marker({ map: map, draggable: true }); google.maps.event.addListener(map, 'click', function(event) { placeMarker(event.latLng); updateMarkerPosition(marker.getPosition()); geocodePosition(event.latLng); }); google.maps.event.addListener(marker, 'position_changed', function() { updateMarkerPosition(marker.getPosition()); geocodePosition(latLng); }); google.maps.event.addListener(marker, 'dragend', function() { geocodePosition(marker.getPosition()); }); } function placeMarker(location) { if ( marker ) { marker.setPosition(location); map.setCenter(location); } else { marker = new google.maps.Marker({ position: location, map: center }); } } var geocoder = new google.maps.Geocoder(); var geoTimer = setInterval(geocoder, 200); var geoIndex = 0; function geocodePosition(pos) { if (geoIndex &lt; 10) { geoIndex++; geocoder.geocode({ latLng: pos }, function(responses, status) { if (status == google.maps.GeocoderStatus.OK) { if (responses &amp;&amp; responses.length &gt; 0) { updateMarkerAddress(responses[0].formatted_address); } else { updateMarkerAddress('Cannot determine address at this location.'); } }else{ alert('Cannot determine address at this location.'+status)} }); } else { clearInterval(geoTimer); } } function updateMarkerPosition(latLng) { document.getElementById('info').innerHTML = [ latLng.lat(), latLng.lng() ].join(', '); } function updateMarkerAddress(str) { document.getElementById('matchAdd').style.display="block"; document.getElementById('address1').value = str; document.getElementById('address').innerHTML = str; } // Onload handler to fire off the app. google.maps.event.addDomListener(window, 'load', initialize); } </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