views:

451

answers:

0

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.