Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps reverse geocode doesn't return correct/accurate address

So I have this specific address: Rijtakker 22, Meijel, Netherlands This is just a normal address that is known by Google Maps, as shown at www.google.nl/maps/place/Rijtakker+22,+5768+Meijel/@51.3482599,5.8857767,17z/data=!3m1!4b1!4m5!3m4!1s0x47c7379f181928e7:0x2a2900b2927e2ebc!8m2!3d51.3482566!4d5.8879654?hl=nl.

In one of my (ASP.NET) applications I've made a web user control where the user types in an address in a Google Maps-esque field, it features suggestions, does autocompleting, et cetera. All pretty standard and based on default Google Maps API behavior / documentation code samples, it's shown in this image. As the user selects an address, one or more Marker objects appear on the map. If only one marker is applicable, that marker's position (lat, lng) is written to a hidden field, if multiple markers are applicable, the position (lat, lng) of a marker being clicked is written to the same hidden field. Upon PostBack, a WebRequest is made to a reverse-geocoding URL to retreive all the address information. Once again, all pretty standard. In case of aforementioned address, the lat and lng values returned in the XML are 51.3482464 and 5.8879746999999725

First weird thing is that when I use a geocoding URL to convert the address to latitude and longitude, I get different results than the markers in my Google Maps user control. The link maps.googleapis.com/maps/api/geocode/xml?address=Rijtakker%2022,%20Meijel,%20Netherlands returns

<location>
    <lat>51.3482464</lat>
    <lng>5.8879747</lng>
</location>

Either way, when reverse geocoding both longitude and latitude values return an address range, or in Google API terms a route, rather than a speficic street_address: Rijtakker 2-40, 5768 Meijel, Netherlands. Rather than the actual correct address. Whether I use a reverse geocoding URL (maps.googleapis.com/maps/api/geocode/xml?latlng=51.3482464,5.8879746999999725 or maps.googleapis.com/maps/api/geocode/xml?latlng=51.3482464,5.8879747) or I use the map examples in Google Maps API documentation (developers.google.com/maps/documentation/javascript/examples/geocoding-reverse)

What am I doing wrong? Is there some limitation in the (reverse) geocoding process where not every address can be accurately converted?

like image 990
Leroy Gerrits Avatar asked Mar 08 '26 13:03

Leroy Gerrits


1 Answers

This is normal behaviour for results that are RANGE_INTERPOLATED

See result's geometry.location.type, see the Developer's Guide for what its values mean. In short, Google Maps does not have the building/house 22 in Rijtakker, Meijel, but it does have a range of address (2-40) and is able to interpolate where 22 would typically be.

Geocoding Rijtakker 2, Meijel and Rijtakker 40, Meijel, results at the start and end of the street.

In contrast, 51.348165,5.887406 returns a ROOFTOP result.

You may also get a RANGE_INTERPOLATED result from reverse geocoding, with a precise address instead of an address range, and that precise address may geocode as a RANGE_INTERPOLATED or ROOFTOP result, if your latlng is closer to an address range than to the actual building.

Example: 51.347234,5.886687 returns "Startebosweg 4, 5768 Meijel", which then geocodes as a ROOFTOP result, and it's location 51.348299,5.886218 geocodes to the same ROOFTOP result. The gap between the 2 latlngs in this paragraph might be due to a glitch in the basemap data.

like image 112
miguev Avatar answered Mar 11 '26 02:03

miguev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!