简体   繁体   中英

(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!! - 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.

So I found the OpenStreetMap - project: http://nominatim.openstreetmap.org/search.php?q= Neustadt &format=json&addressdetails=1 ( example )

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 . Instead of using simple queries try structured requests :

Note that you can't combine a structured query with the q=<query> parameter.

And please comply with Nominatim's usage policy , this service runs on donated resources and has limited capacity. If you need to run more frequent queries then either choose one of the alternative instances or install and run your own instance .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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