Nearest Zip Code Search using asp.net
I want to inplement functionallity that will search zip codes, if user enter any zip code 开发者_如何学JAVAthan 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.
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.
精彩评论