I want to get the name of the city from the GPS coordinates. I can get the details of the GPS points using Google API
http://maps.googleapis.com/maps/api/geocode/output?parameters
Where output is XML which I don't want to be... For example
http://maps.google.com/maps/api/geocode/xmllatlng=53.244921,-2.479539&sensor=false®ion=gb
returns me the XML details of the coordinates.... Which I don't think is easy to get the name of the City.... I want only the name of the city.. Thanks for you help in advance
The correct URL is below
http://maps.googleapis.com/maps/api/geocode/xml?latlng=53.244921,-2.479539&sensor=true
In anycase, the xml is perfectly fine to get a city. In this case
<address_component>
<long_name>Northwich</long_name>
<short_name>Northwich</short_name>
<type>postal_town</type>
</address_component>
is what you are looking for. Not sure what language you are wishing to get this information from in though. From the looks of your other questions you work with javascript. So i suggest learning how to XML parse with javascript.
SO has a great post on this here
来源:https://stackoverflow.com/questions/10913870/get-city-name-from-gps-co-ordinates