You know when you go on a search of some sort and they
sometimes ask you for
your zip. Then when you submit, it finds items close to your
zipcode
(surrounding cities)?? How do you do that?
They have a database that contains zip codes and the
longitude and
latitude coordinates of the center of the zip codes. They
then use a
formula ranging from basic algebra to fancy calculus that
takes into
count the curvature of the earth to find all other zip codes
centers
within a given distance.
There are many sources of the zip code database from free to
costly.
The formulas can easily be found on Google as well as step by
step
tutorials on how to put it all together.
I wrote an app a few years ago that tells distance between
zipcodes. You need to have a table with all the zipcodes in it
along with the Long and Lat of the zipcodes. If two zips are
entered submitted, you just use the associated Lat & Long to
calulate the distance between the two points. I think I got the
zipcode database from the US postal service site.