문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top