Google Map API V3 geocoder not showing correct location

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

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

Please see the following screenshot here: Wrong Correct

My codes for V3 are as follows:

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 a better way to get accurate results in V3 API? Thank you

+3
source share
2 answers

Record the value of the location property and verify that the coordinates are correct.

Submit the addMarker method code.

0
source

- -, JSON XML, , . Google Maps v3

0

Source: https://habr.com/ru/post/1747668/


All Articles