I recently developed a dealer geolocation platform with Google Maps V3 Js API, however I realized that when the user enters a zip code, geolocation is poor.
For example, if the user searches 13001 (1st district of Marseilles), geolocation is done on Aix-en-Provence (whose INSEE code is 13001). Ditto for 13007 (7th arrondissement of Marseille), returns Auriol 20km from Marseille.
It seems that this is the following piece of code that returns the wrong coordinates :
function GoogleGeocode(){
geocoder = new google.maps.Geocoder();
this.geocode = function(address, callbackFunction) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var result = {};
result.latitude = results[0].geometry.location.lat();
result.longitude = results[0].geometry.location.lng();
callbackFunction(result);
} else {
if (settings.geocodeErrorAlert != "") {
alert(settings.geocodeErrorAlert + status);
}
callbackFunction(null);
}
});
};
}
Do you have an explanation and a solution to solve this problem?
Thank you all