Nearest Zip Code Search using asp.net

允我心安 提交于 2019-11-29 16:29:30
Ed Bayiates

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!