I've 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}®ion={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®ion=nz
Then you can use that XML to get whatever details you need, including the City
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With