开发者

City By GPS Location Latitude/Longitude

I've go开发者_如何学Got a latitude/longitude value.... How can I search and get the city?


If you're looking for free (as freedom) sources, you can use Geonames API findNearbyPlaceName.

For example the following returns nearest Placename:

http://api.geonames.org/findNearbyPlaceName?lat=47.3&lng=9&username=demo

More information is available here

http://www.geonames.org/export/web-services.html#findNearbyPlaceName

Another option is getting data from Freebase. Instead of single point it takes bounded box:

http://api.freebase.com/api/service/geosearch?location=[30.2,50.4,30.6,50.8]&location_type=/location/citytown&inside=true&indent=1


Using the google maps api, here is an example to get the address in XML format.

http://maps.google.com/maps/api/geocode/xml?latlng={latlng}&sensor={sensor}&region={region}

Where latlng = 0,0 sensor = false, and region = country code, so for my old address it would be

http://maps.google.com/maps/api/geocode/xml?latlng=-43.893792,171.7592620&sensor=false&region=nz

Then you can use that XML to get whatever details you need, including the City

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜