If you are making an app that has its own addresses database running on the backend and then use an API to fetch the location on the frontend, you might have noticed that the Google API you are using isn’t pointing to the exact map location that you have entered. While if you enter the same on Google Maps it would show you a much accurate position. The issue is mainly due to the Google API we are using to fetch the longitude and latitude.
When using GeoCoding Google API and say searching for a location: 707 Charlotte St. Peterborough, Ontario, K9J 7B3 Canada, your API and Google Map might show longitude and latitude values as:
Geocoding Google API
Latitude: : 44.3000488,
If you compare both these you would see how slight difference in decimals is there which is uncontrollable since the API calculates these values itself.
The only way out here is to look for each location not showing exactly via your API on Google Map manually and then inserting the longitude and latitude generated by the map on your backend.
Now, if you use the “Google Places API” you would see that either the API would show you an exact location using the longitude and latitude generated or it won’t show you any results at all i.e. the longitude and latitude fields would be empty as shown here for the address: “001 12E Avenue Nord, Service D’Immunologie-Allergologie, Sherbrooke, Quebec, J1H 5N4, CANADA”
However, if you remove some part of this address say “Service D’Immunologie-Allergologie 3001” you would be able to see some nearby places on Google Map and hence can take the longitude and latitude of any nearby place to trace your address. Now these nearby place longitude and latitude are to be inserted into the backend against this address.
So far, this is what we have been able to deduce that you need to manually check your locations for exact location pointers or you can compromise on nearby location pointers.
If you come up with some better solution, don’t forget to write to us!