I am using the Google Maps API (https://maps.googleapis.com/maps/api/geocode/xml) to geocode places and addresses. However, the results seem inconsistent. The administrative_area_level_2 and locality OR the locality and sublocality_level_1 seem to overlap. But, depending on the address, the overlap is different. One of the things I need to do is determine the city. The documentation states that the locality is the equivalent of a city depending on the country.
If I geocode "Noord-Holland, Nederland" which is a province I get:
I can understand. All seems well...
If I geocode "Amsterdam, Noord-Holland, Nederland" I get the following result:
Here I start not understanding the result. Why is Amsterdam listed as an administrative_area_level_2 as well as a locality? Maybe there is a higher governamental body with the same name? But ok, Amsterdam is the locality, thus the city. Which is correct.
If I geocode "Anton de Komplein 150, 1102 CW Amsterdam, Noord-Holland, Nederland" I get the following results:
Now I really don't understand.
Can someone explain how i should interpretate the results?
I've had a look at your examples and I believe these are data issues that should be reported to Google.
Let's explain my findings:
The request for 'Amsterdam, Noord-Holland, Nederland'
https://maps.googleapis.com/maps/api/geocode/json?address=Amsterdam%2C%20Noord-Holland%2C%20Nederland&key=MY_API_KEY
returns the following address components for me
"address_components":[
{
"long_name":"Amsterdam",
"short_name":"Amsterdam",
"types":[
"locality","political"
]
},
{
"long_name":"Government of Amsterdam",
"short_name":"Government of Amsterdam",
"types":[
"administrative_area_level_2","political"
]
},
{
"long_name":"North Holland",
"short_name":"NH",
"types":[
"administrative_area_level_1","political"
]
},
{
"long_name":"Netherlands",
"short_name":"NL",
"types":[
"country","political"
]
}
]
Note that administrative_area_level_2 has a name 'Government of Amsterdam'. I understand you might be using the Dutch language to get results
https://maps.googleapis.com/maps/api/geocode/json?address=Amsterdam%2C%20Noord-Holland%2C%20Nederland&language=nl&key=MY_API_KEY
In this case I have:
{
"long_name":"Amsterdam",
"short_name":"Amsterdam",
"types":[
"locality","political"
]
},
{
"long_name":"Amsterdam",
"short_name":"Amsterdam",
"types":[
"administrative_area_level_2","political"
]
}
So at this point it looks like the Dutch version is not translated correctly, we have 'Government of Amsterdam' in English and 'Amsterdam' in Dutch. This is a data issue. By the way you can see the administrative area level 2 here:
https://www.google.com/maps/place/Government+of+Amsterdam,+Amsterdam,+Netherlands/@52.3544136,4.7585038,11z/data=!3m1!4b1!4m5!3m4!1s0x47c63fb5949a7755:0xe4f20c148755745!8m2!3d52.3666969!4d4.8945398
The second example is a bit more complicated.
https://maps.googleapis.com/maps/api/geocode/json?address=Anton%20de%20Komplein%20150%2C%201102%20CW%20Amsterdam%2C%20Noord-Holland%2C%20Nederland&key=MY_API_KEY
First of all you should be aware that for street address level searches you will get address components and formatted address in local language as described in the localization of street addresses article. So doesn't matter what language we specify English or Dutch we will see the Amsterdam as the administrative area level 2 and this is exactly the same data issue that we faced in the first example, it should be translated to 'Regering van Amsterdam' on Google side.
Referring to the locality component. It's really weird that Amsterdam-Zuidoost is defined as locality in Google database. I can see it as shown in the screenshot and it looks like a sublocality:
https://www.google.com/maps/place/Amsterdam-Zuidoost,+Netherlands/@52.2569773,4.995519,12z/data=!4m5!3m4!1s0x47c60c069aab8879:0x249b64218cad1744!8m2!3d52.3079989!4d4.9715451
However if you check this feature in the Geocoder tool, it clearly states that this is a locality feature:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJeYirmgYMxkcRRBetjCFkmyQ
Note the pace ID is ChIJeYirmgYMxkcRRBetjCFkmyQ. I believe this also might be a data issue on Google side.
I would suggest sending a feedback to Google data team following the Google Maps help center:
https://support.google.com/maps/answer/3094045?hl=en&ref_topic=3093612
I hope my answer clarifies your doubts!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With