简体   繁体   English

(PHP)按用户输入的城市列表

[英](PHP) List of Cities by user input

I need a free (and maybe an open-source) service to get a list of cities (towns, villages, hamlets) , with some data like: - geoCoords [LAT|LON] //very important!! 我需要一个免费的(也许是开源的)服务来获取城市(城镇,村庄,小村庄)的列表 ,并提供以下数据:-geoCoords [LAT | LON] //非常重要! - district - region/county - state - (maybe zipcode) -地区-地区/县-州-(也许是邮政编码)

The user types his place of residence in an input field and get a list of cities from which he/she can choose his own city. 用户在输入字段中键入他的居住地,并获得一个城市列表,他/她可以从中选择自己的城市。 (maybe displaying with some infos like county or state or whatever) - And I need to save the geoCoords [LAT|LON] into my database for calculating distances to other users later. (也许显示一些信息,例如县,州或其他信息)-而且我需要将geoCoords [LAT | LON]保存到我的数据库中,以便以后计算与其他用户的距离。

So I found the OpenStreetMap - project: http://nominatim.openstreetmap.org/search.php?q= Neustadt &format=json&addressdetails=1 ( example ) 因此,我找到了OpenStreetMap-项目: http://nominatim.openstreetmap.org/search.php?q= &format=json&addressdetails=1 Neustadt &format=json&addressdetails=1 示例

This looks fine, but I need a way to filter the results. 看起来不错,但我需要一种过滤结果的方法。 Because I don't need bus/rail stations or shopping malls. 因为我不需要公共汽车站/火车站或购物中心。 Only locations/settlements (cities/towns, villages/suburbs/hamlets) where people live. 仅在人们居住的位置/住区(城市/城镇,村庄/郊区/小村庄) And - if it's possible - also filtered by country (in this case: Germany) . 并且-如果可能的话-还按国家/地区过滤(在这种情况下:德国)

Does anyone have some ideas? 有人有想法吗? :) :)

Take a look at the Nominatim documentation in the OpenStreetMap wiki . 看一下OpenStreetMap Wiki中的Nominatim文档 Instead of using simple queries try structured requests : 不要使用简单的查询,而是尝试使用结构化请求

Note that you can't combine a structured query with the q=<query> parameter. 请注意,您不能将结构化查询与q=<query>参数结合使用。

And please comply with Nominatim's usage policy , this service runs on donated resources and has limited capacity. 并且请遵守Nominatim的使用政策 ,此服务在捐赠的资源上运行且容量有限。 If you need to run more frequent queries then either choose one of the alternative instances or install and run your own instance . 如果您需要运行更频繁的查询,则可以选择其他实例之一,也可以安装并运行自己的实例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM