我如何从谷歌地图获得最近的重要城镇或城市?

发布于 2024-11-27 21:20:15 字数 93 浏览 1 评论 0原文

这可能吗?

我的用户会在地图上显示他们居住的位置,如果这不是一个大城镇或城市,我想找到它并将此信息与用户记录相关联。

知道如何做到这一点吗?

Is this possible?

I have users who will show where they live on a map, if this isn't a large town or city, i'd like to find that and associate this information with the users record.

Any idea how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沦落红尘 2024-12-04 21:20:15

为什么不使用 GeoNames Web 服务。您可以下载完整的转储

它以 Lat/Lng 作为参数,还有一个可选参数,称为半径(以公里为单位的距离)以及参数城市,其中:

cities1000.zip:所有人口>的城市1000 或 座位
adm div(约 80.000)

cities5000.zip:所有人口>的城市5000 或 PPLA(约
40.000)

cities15000.zip:所有人口>的城市15000或大写字母
(约 20.000)列

Why not use the GeoNames Web Service. You can download the complete dump.

It takes Lat/Lng as parameters and also there is an optional parameter called radius(distance in km) as well as parameter cities where:

cities1000.zip : all cities with a population > 1000 or seats of
adm div (ca 80.000)

cities5000.zip : all cities with a population > 5000 or PPLA (ca
40.000)

cities15000.zip : all cities with a population > 15000 or capitals
(ca 20.000)columns

往日情怀 2024-12-04 21:20:15

我意识到这是一篇旧帖子;然而,我发布我的观点是为了那些在研究中偶然发现这篇文章的人(就像我一样)的利益。

为了找到最大/最近的大城市/城镇,您需要定义“大”。

  1. 什么是大城市/城镇?这完全是主观的——我的定义与你的不同。地图服务无法决定“大”的定义。

  2. 大城市优先?假设即使您以某种方式实现了第一,您将如何确定优先顺序。一个“小”城镇 X 附近可能有 2 个大城市 - A 和 A。 B. 您会接受哪一个?

基于以上两种说法,我建议您不要这么做;但是,如果您无法避免这种情况,则需要在应用程序中添加自定义逻辑。示例:获取 25 英里内的所有位置,然后自行决定要保存的位置。

I realize this is an old post; however, I'm posting my views for the benefit of the people who stumble upon this post (like I did) in their research.

In order to find the largest/closest large city/town you would need to define 'large'.

  1. What is a large city/town? This is completely subjective - my definition will be different from yours. A mapping service, cannot decide the definition of 'large'.

  2. Priority of large cities? Let's say even if you somehow achieved #1, how will you prioritize. A 'small' town X might have 2 large cities close to it - A & B. Which one would you accept?

Based on the two statements above, I advice you against it; however, if it is impossible for you to avoid this, you would need to put in custom logic in your application. Example: Get all locations within 25 miles and decide for yourself what place you want to save.

献世佛 2024-12-04 21:20:15

我有一段时间努力寻找最好的方法来做到这一点。谷歌的API在解码坐标时似乎主要使用地址/城镇边界,这是没有帮助的。

如果您在美国,国家气象局的 API 是完美的选择。给定美国的坐标,它可以提供最近的城镇/人口普查指定地点以及该点距城镇的距离和方向。

我创建了一个基本网站来尝试 https://nearest.town/

I struggled to find the best way to do this for a while. Google's API seems to mostly use addresses/town boundaries when decoding coordinates, which is unhelpful.

If you're in the United States, the National Weather Service's API is perfect. Given coordinates in the US, it can provide the nearest town/census-designated place and the point's distance and direction from the town.

I created a basic site to try it out at https://nearest.town/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文