In google map, when I drag the lat() and lng() marker, the values specified in the text fields. I want to do this:
Changes the coordinates for each movement.
My code parts work for me. But, when I drag the marker far, it works, but in small distances lat() and lng() do not change?
How can I solve this problem?
Basic js codes:
// fill in the UI elements with new position data function update_ui(address, lat, lng) { $('#lat').val(lat); $('
And geocode:
geocoder.geocode(request, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { // Google geocoding has succeeded! if (results[0]) { // Always update the UI elements with new location data update_ui(results[0].formatted_address, results[0].geometry.location.lat(), results[0].geometry.location.lng()) // Only update the map (position marker and center map) if requested if (update) { update_map(results[0].geometry) } } else { // Geocoder status ok but no results!? alert("Error occured. Please try again."); } } else { // Google Geocoding has failed. Two common reasons: // * Address not recognised (eg search for 'zxxzcxczxcx') // * Location doesn't map to address (eg click in middle of Atlantic) if (type == 'address') { alert("Sorry! We couldn't find " + value + ". Try a different search term, or click the map."); } else { alert("Sorry! We couldn't find " + value + ". Try a different search term, or click the map."); update_ui('', value.lat(), val.lng()) } }; });
Edit:
When I drag the marker very little, the coordinates do not change, but after some movement they change. Here is the jsfiddle:
http://jsfiddle.net/jhoonbey/wwdE9/
javascript google-maps google-maps-api-3 geocoding google-maps-markers
Jhoon Bey Jul 11 '13 at 7:22 2013-07-11 07:22
source share