Question

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.

Was it helpful?

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).

OTHER TIPS

One solution is to make two API calls, one with "Barcelona", and another one with "Barcelona region", so that I get both results, the locality and the administrative_area. But as said, it would be preferable to do it in a single API call.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top