javascript 用于加载国家、州/省/地区和城市选择菜单数据的 API 或数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6659269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 21:26:49  来源:igfitidea点击:

API or database to load data for Country, State/province/region, and city select menus

javascripthtmldatabasejsonapi

提问by Test Tester

anyone know of a solution? i have found online a select menu for countries, but i need either an API or a database with every state/province and major city in each country.

有人知道解决方案吗?我在网上找到了一个国家选择菜单,但我需要一个 API 或一个数据库,其中包含每个国家/地区的每个州/省和主要城市。

采纳答案by Yanick Rochon

Take a look at GeoNames. You can download (just about) everything they have and create your own local databases, or you can use their REST WebserviceAPI. As an added bonus, they even have already made client libraries.

看看GeoNames。您可以下载(几乎)他们拥有的所有内容并创建您自己的本地数据库,或者您可以使用他们的 REST Web 服务API。作为额外的奖励,他们甚至已经制作了客户端库

回答by z0r

If you just want users to be able to select a location, you could use a search-based interface such as OSM Nominatim. You can download the data and install it yourself, or just use their web services (subject to usage limits). Indeed, you might be able to download the Nominatim database and write a different API to use menus to drill down.

如果您只希望用户能够选择一个位置,您可以使用基于搜索的界面,例如OSM Nominatim。您可以下载数据并自行安装,或仅使用他们的网络服务(受使用限制)。实际上,您可以下载 Nominatim 数据库并编写不同的 API 以使用菜单进行深入分析。