使用 asp.net 搜索最近的邮政编码
我想实现搜索邮政编码的功能,如果用户输入任何邮政编码,则将显示所有接近输入邮政编码的邮政编码。请告诉我们是否有任何免费的 api,例如 Google API 或任何其他解决方案。
I want to inplement functionallity that will search zip codes, if user enter any zip code than all the zip codes close to entered zip code will be shown. Please let us know if there is any free api for it like Google API or any other solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,获取一个免费的邮政编码数据库,例如这个。这将允许您将输入的邮政编码转换为纬度和经度。只要您还创建纬度和经度数据库键,您现在就可以查找所有附近的纬度和经度(通过在排序值中上下移动)并获取所需距离内的所有邮政编码。
以下是如何计算的示例纬度和经度距离。
First, grab a free zip code database like this one. This will allow you to convert from an entered zip code to a latitude and longitude. As long as you make latitude and longitude database keys also, you can now look up all the nearby latitudes and longitudes (by moving up and down in the sorted values) and get all ZIP codes within a desired distance.
Here is an example of how to calculate latitude and longitude distances.
我没有深入研究过,但 USPS 提供了许多 API 和数据库。您可能想查看他们的地址信息 API。如果有人拥有准确的数据库,那可能就是美国邮政局。
https://www.usps.com/business/webtools.htm
他们有一些网络允许您手动查找城市邮政编码的工具,因此您可能可以使用类似的功能。
I haven't explored it much, but the USPS offers a number of API's and databases. You might want to check out their Address Information API. If anyone has an accurate database, it's probably the USPS.
https://www.usps.com/business/webtools.htm
They have some web tools that allow you to manually look up zip codes for a city, so there might be similar functionality you can use.
我在地址验证领域工作,我们在这方面有一些经验),其中“邮政编码”和“地理编码”是流行词。为了进一步提高位置准确性,您需要考虑验证完整的地址并添加 ZIP+4 代码。这将为您的用户提供更相关的结果。
一般来说,免费服务不会提供这种价值,但有一些经 USPS 正式许可或认证的经济实惠的选项来分发该数据。其中一项服务是 LiveAddress(我自己开发过的一项服务)。 ZIP+4 代码比通用邮政编码更准确,因此您将获得更准确的地理定位结果。
I work in the address verification field, where we have some experience doing this) where "ZIP codes" and "geocoding" are buzz-words. For further location accuracy, you will want to consider verifying a complete address and adding the ZIP+4 code. This will provide more relevant results to your user.
Generally, free services won't provide that kind of value, but there are some affordable options that are officially licensed, or certified, by the USPS, to distribute that data. One such service is LiveAddress (a service I've worked on myself). The ZIP+4 code is more accurate than a generic ZIP code, so you'll get more accurate geolocated results.