是否有公共地理定位系统可以查询当地城市的名称?
我希望尝试简化系统中的地址输入,其中城市文本框最初由用户的地理位置填充自动建议。在过去,在不首先知道省/州/国家的情况下自动提示城市名称似乎成本高昂,但要求用户向后输入地址是没有意义的,因为我们不以这种方式考虑地址信息。另一方面,不自动暗示城市名称意味着我们最终会得到来自世界各地拼写错误的城市的各种奇怪而精彩的条目。
我想知道是否有一种服务可以查询,该服务不仅会根据用户在文本框中输入的内容,还会根据用户所在的国家和政治边界自动响应最合适的城市名称?
例如,如果我在加拿大,并且我输入“Mi”,那么我会看到加拿大境内以“Mi”开头的所有城市,直到确定我输入的信息不是加拿大的此时,它会根据我们的使用模式使用下一个最有可能配置的国家/地区 - 即接下来会检查美国,然后是墨西哥,然后是其他不太可能的目的地。如果我有数据库,我可以自己编写所有这些内容,但我不知道在哪里可以找到数据库,而且我怀疑它的可扩展性比查询网络上预先存在的服务要差。
I'm looking to attempt to simplify address entry into a system where the city textbox has autosuggest initially populated by the user's geolocation. In the past it has seemed that autosuggesting the city name is prohibitively costly without knowing the province/state/country first but it doesn't make sense to require the user to enter the address backwards as we don't think about address information this way. On the other hand, not autosuggesting the city name means we end up with all sorts of weird and wonderful entries for mis-spelled cities from around the world.
I was wondering if there's a service that I can query that would automatically respond with the most appropriate city names according to not only what the user enters in the textbox, but the location of that user based on the country and political boundary they fall within?
For instance, if I am in Canada [as I am] and I enter 'Mi' then I'd be presented with all cities within Canada starting with 'Mi' until it was determined that the information I was entering wasn't Canadian at which point, it would use the next most likely configured country based on our usage pattern - i.e. it would check the U.S. next, followed by Mexico and then other less likely destinations. I can write all this myself if I had the database but I don't know where I can find one and my suspicion is that it would be less scalable than querying a pre-existing service on the web.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 MaxMind 提供了一个免费数据库,您可以下载 CSV 格式的数据库:
有一个在线演示如果您愿意,可以测试一下,但无法通过网络服务查询它。
IPInfoDB 还提供可供下载的数据库 - 他们有下载。 com/ip_location_api.php" rel="nofollow noreferrer">XML API,但它仅支持查找特定 IP 的城市/国家。您正在尝试做一些比这更广泛的事情,寻找特定国家/地区的每个城市,并根据 IP 选择国家/地区。我没想到有一个网络服务可以做到这一点,这是一个非常具体的要求。
编辑添加:您可以使用 IPInfoDB API 查找国家/地区,然后从当地国家/城市数据库生成自动完成建议。这样,所有 IP 地理定位就不需要在本地完成。您可以在多个地方获取特定国家/地区的城市列表。例如,以下是国家地理空间情报局维护的一些综合列表机构
Looks as though MaxMind offers a free database that you could download in CSV:
There's an online demo to test it a bit if you'd like, but no way to query it through a web service.
IPInfoDB also has their database available for download - they have an XML API, but it only supports looking up the city/country for a particular IP. You're trying to do something a little more wide than that, looking for every city in a particular country, with country selected based on IP. I wouldn't expect that there's a web service for that, it's a pretty specific requirement.
Edited to add: You could use the IPInfoDB API to look up the country though, and then generate the autocomplete suggestions from a local country/city database. That way all the IP-geolocation wouldn't need to be done locally. There are various places that you can get a list of cities in a particular country. For example, here's some comprehensive lists maintained by the National Geospatial-Intelligence Agency