Get City name from GPS co-ordinates

Deadly 提交于 2019-12-05 03:01:36

问题


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&region=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


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!