I've seen several web sites where one can enter a zip code and a mileage amount, and then a list of stores, doctors, and other information within the defined region is returned. How is this done?
The trick is to use longitude and latitude settings. Each zip code is centered around a particular longitude and latitude intersection, and you'll need a table containing these values. Lists are available on the Web. Some cost a bit, but others are free—run a search with "zip," "longitude," and "latitude" as keywords, and you're bound to find many choices.
Figure 9-27 shows a section of a table that contains the necessary information.
Figure 9-27. Table of zip codes
Now, let's consider the process. When a user enters a zip code on the web page, it has to be found in the zip code table to access its longitude and latitude values. A second scan of the zip table is then run to identify zip codes near the entered zip code. How near is "near" depends on the selected mileage setting. There is a formula to calculate what other zips are within the mileage parameter.
Longitude and latitude are measured in degrees, minutes, and seconds. Roughly, a degree is 69 miles, a minute is one-sixtieth of a degree (or 1.15 miles), and a second is about 100 feet.
These are approximations—nautical miles are measured differently than land miles, and there are other ...