Geocode does not locate the point exactly on google map

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); $('#lng').val(lng); } // move the marker to a new position, and center the map on it function update_map(geometry) { map.fitBounds(geometry.viewport) marker.setPosition(geometry.location) } 

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/

0
javascript google-maps google-maps-api-3 geocoding google-maps-markers
Jul 11 '13 at 7:22
source share
1 answer

The problem is that you are passing the marker position through a geocoder.

The geocoder takes the original lat / lng location and tries to match it to the address. It can be a street or a city or region. The results returned by the Google geocoder include the text of the address as well as the location of that address.

You show the location that the geocoder returns. When a user moves a marker across regions with a low density of potential addresses, you will see anti-aliasing. This means that the different source locations that the user selects will drop the geocode to the same address that is returned by the geocoder.

This way it will look as if the lat / lng of the marker has not changed when what you actually do displays the lat / lng of the geocoded address.

Please note: this site with which you are associated does not perform geocoding when displaying location information.

+1
Jul 11 '13 at 12:59 on
source share
— -



All Articles