将纬度/经度转换为城市名称? (反向地理定位) [英] Converting latitude/longitude into city name? (reverse geolocating)
问题描述
我希望能够将地理定位从经度/纬度转换到设定的水平(理想情况下,城市名称),以便在搜索结果中我可以列出这样的位置:10英里外的罗得岛州普罗维登斯,5英里外的罗得岛州普罗维登斯,16英里外的罗德岛克兰斯顿,。 p>
有没有办法将地理编码反向到城市?我看到很多例子来说明如何将地理编码反转到最近的可寻址位置,但无法控制关卡。 b
$ b
希望这是明确的!随时评论你需要澄清的任何问题。
> Google地理编码器,支持反向地理编码返回 address_components 的。如果您只想要城市名称,您只需将标记为 locality
和 political
的地址组件拉出。如果您想要州,那么它们会被标记为 administrative_area_level_1
I'm working on a job board in Codeigniter PHP + jQuery where employers enter their location and we use Google Maps API to plot it. While this has had awesome usability results, the problem is when we try to display these locations to job seekers they are muddled and hard to visually discern (they read like this: "02905, 2 miles away","171 John St., 4 miles away", "Providence, RI, 10 miles away".
I want to be able to reverse geolocate from a longitude/latitude to a set level (ideally, city name) so that in the search results I can have the locations be listed like this: "Providence, RI, 10 miles away", "Providence, RI, 5 miles away", "Cranston, RI, 16 miles away".
Is there a way to reverse geocode to city? I see many examples for ways to reverse geocode to nearest addressable location, but no way to control the level.
Hope that's clear! Feel free to comment with any questions you need clarification on.
The Google Geocoder, which supports reverse geocoding returns address_components. You just need to pull out the component of the address tagged with locality
and political
if you just want the city name. If you want states as well they are tagged with administrative_area_level_1
这篇关于将纬度/经度转换为城市名称? (反向地理定位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!