从GPS坐标获取城市名称 [英] Get City name from GPS co-ordinates

查看:268
本文介绍了从GPS坐标获取城市名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从GPS坐标中获得城市的名称. 我可以使用Google API获取GPS点的详细信息

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

输出是我不想成为的XML ... 例如

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

向我返回了坐标的XML详细信息....我不容易得出城市的名称.... 我只想要城市的名字.. 感谢您的提前帮助

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

推荐答案

正确的URL在下面

http://maps.googleapis.com/maps/api/geocode/xml?latlng=53.244921,-2.479539&sensor=true

在任何情况下,使用xml都可以很好地到达城市.在这种情况下

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>

是您要寻找的. 虽然不确定您希望从哪种语言中获取此信息. 从其他问题的外观来看,您可以使用javascript. 因此,我建议学习如何使用JavaScript进行XML解析.

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在此处上有一篇不错的文章

SO has a great post on this here

这篇关于从GPS坐标获取城市名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆