Getting city from geocode results Google Maps Api

Viewed 1830

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:

  • country:Nederland
  • administrative_area_level_1: Noord-Holland

I can understand. All seems well...

If I geocode "Amsterdam, Noord-Holland, Nederland" I get the following result:

  • country:Nederland
  • administrative_area_level_1: Noord-Holland
  • administrative_area_level_2:Amsterdam
  • locality:Amsterdam

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:

  • country:Nederland
  • administrative_area_level_1:Noord-Holland
  • administrative_area_level_2:Amsterdam
  • locality:Amsterdam-Zuidoost
  • sublocality_level_1:Amsterdam-Zuidoost

Now I really don't understand.

  1. Here is Amsterdam-Zuidoost mentioned twice
  2. Why is the locality here "Amsterdam-Zuidoost"? It is not the city... I would have assumed that "Amsterdam" would be the locality and "Amsterdam-Zuidoost" the sublocality_level_1.

Can someone explain how i should interpretate the results?

1 Answers
Related