I'm in a project where I need to develop a map that searches for a nearby store when someone types in their zip code. An example of this can be found here:
Find a Jimmy John's
Has anyone ever made one of these? I've been searching the web and found tons of sites (basically any big retailor) who uses this function but no documentation on how to do it.
Yeah I did something like this a few years ago...
For the calculation of distances, you just need latitude/longitude for the location from which you are basing the distance search (zip code or town), and then you also need to store the lat/long for each of your "stores".
With this data, you can the use Pythagoras to calculate the distance between the two points and select the relevant stores.
The less precise you need to be with this, the simpler it becomes.
For example, if you want to search extremely precisely within a given (circular) radius, you'll need to have the exact lat/long for the store and zip code and use Pythagoras.
If you're happy to search in a square distance from a point rather than a circle, then you don't need Pythagoras.
If you don't need to be as precise with the distance either, it's likely that you'll need less lat/long data for the zip codes too.
I don't know how the format of zip codes work, but I'm assuming they're similar to UK post codes.
If you need the precise data for each individual postcode, you're looking at data that you'd have to pay for as it's not in the public domain, and also 2.4 million records.
If you reduce the accuracy to just the outcode, which is accurate to a couple of miles, then you'd only need around 3000 lat/long records, and this data is freely available too.
Depends on the density of your stores really but it's definitely worth only being as accurate as you need to be.
I'm rambling now so let me know if there's anything specific you want to know.
Hope there was something useful in there