Google Map API V3 geocoder not showing the correct place

Posted by TTCG on Stack Overflow See other posts from Stack Overflow or by TTCG
Published on 2010-05-29T14:18:38Z Indexed on 2010/05/29 14:22 UTC
Read the original article Hit count: 306

I am upgrading my codes from Google Map API V2 to V3. In V2, I used GlocalSearch to get the latitude and longitude for the given address.

In V3, I saw google.maps.Geocoder() and try to get the similar detail. However, the lat & long given by the V3 function is not accurate.

Pls see the following screenshot here: Wrong Correct

My codes for V3 are as follow:

var geocoder = new google.maps.Geocoder();
function codeAddress(address) {
    if (geocoder) 
    {
        address = address + ", UK";

        geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var latlng = results[0].geometry.location;              
                addMarker(latlng); //Adding Marker here             
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    }
}

Is there better way to get the accurate result in API V3? Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about geocoding