将纬度/经度转换为城市名称? (反向地理定位) [英] Converting latitude/longitude into city name? (reverse geolocating)

查看:159
本文介绍了将纬度/经度转换为城市名称? (反向地理定位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Codeigniter PHP + jQuery工作板上工作,雇主输入他们的位置,我们使用Google Maps API来绘制它。虽然这有很棒的可用性结果,但问题是,当我们尝试向求职者展示这些位置时,他们混淆不清,难以在视觉上辨别出来(他们这样读:02905,2英里远,171 John St.,4 ,普罗维登斯,RI,10英里远。

我希望能够将地理定位从经度/纬度转换到设定的水平(理想情况下,城市名称),以便在搜索结果中我可以列出这样的位置: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屋!

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