Search code examples
google-mapsgoogle-geocoder

Google Maps Geocode get both locality and administrative_area when named equal


I've a problem with the Google geocoder, when searching for Barcelona which could resolve to the province (administrative_area) of Barcelona, or the Barcelona city (locality) I only get the later with the Google API.

I would like to retrieve both places in a single API call to Google. Not sure if it's possible, I've looked their API and I didn't found anything.


Solution

  • The result is the same with the Geocoding API web-service. This request

    http://maps.googleapis.com/maps/api/geocode/json?address=barcelona&sensor=false

    also gives the city data as a response, even with using different component filters. I tried to geocode New York for a comparison:

    http://maps.googleapis.com/maps/api/geocode/json?address=new+york&sensor=false

    The result is the same. It seems if a city and a region exists, the response contains only the city (the last link in the hierarchy).