开发者

Can i get geocoding information from Google Geocoding API passing only the city?

I just need to fetch some geo data for a given city, i'm not interested (and i don't know) the address. Sending a request like this:

http://maps.googleapis.com/maps/api/geocode/xml?address=fake,%20USA&sensor=false

will match a street with开发者_高级运维 whe word fake in it, somewhere in USA. How can i match only cities and get ZERO_RESULTS response if there is no city with that name?


You can't do this with the Geocoding API unfortunately, from the docs page:

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739)

The API will always look for a specific address and if it can't find an exact match from the string you provide it will always make a 'best effort' guess as to what you meant to try and find one. Only if it can't make this reasonable guess wil it return ZERO_RESULTS.


I also just explore the API.how about using link like below

http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:US

locality equal to City and stated the country as US.It will return zero result.But if using this

http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:Nigeria

This will return the result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜