Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Zip code proximity searches

1. ## Zip code proximity searches

I'd like to implement zip code proximity searches. What is required to do the search? Can anyone recommend any pre-made zip code proximity search scripts that I should look into?

Thanks.

• I assumed you looked here first?

http://www.mattcutts.com/blog/fun-with-zip-codes/

There are so many variations to zip code finding, nearest zip code, maps, etc.
You'll need to either be more specific, or give us an example of one you've seen.

• It's a matter of getting the latitude and longitude of point A and point B (you'll want to access a database for that, there are free ones available) and then calculate distance from A to B.

PHP Code:
``` //getDistance(\$lat1,\$log1,\$lat2,\$log2) function getDistance(\$a1,\$b1,\$a2,\$b2) { \$r = 3963.1; //3963.1 statute miles; 3443.9 nautical miles; 6378 km \$pi = 3.14159265358979323846; //print "\$a1, \$b1, \$a2, \$b2, \$r, \$pi\n"; \$a1 = \$a1*(\$pi/180); \$a2 = \$a2*(\$pi/180); \$b1 = \$b1*(\$pi/180); \$b2 = \$b2*(\$pi/180); \$ret = (acos(cos(\$a1)*cos(\$b1)*cos(\$a2)*cos(\$b2) + cos(\$a1)*sin(\$b1)*cos(\$a2)*sin(\$b2) + sin(\$a1)*sin(\$a2)) * \$r) ; //print "-- \$ret--\n"; return \$ret; }  ```
I got this snippet from http://www.idealog.us/2006/07/zip_code_distan.html

• google actually has the whole of the US geocoded.

I have a mysql script that does this nicely, even with it's limited spatial support!

I'll see if I can look it out

• Originally Posted by mlseim
There are so many variations to zip code finding, nearest zip code, maps, etc.
You'll need to either be more specific, or give us an example of one you've seen.
The type of zip code proximity search I'm interested in is the type that you see in car dealership sites - i.e. you enter your zip code, and then in a drop-down menu you choose your search radius: 5 or 10 or 15 miles etc. and depending on what you choose the dealerships within that range show up.

I've searched on google, but haven't found anything worthwhile yet.

@brazenskies:
If you can find that script you mentioned, I'd be very interested in looking at it.

Thanks.

• http://www.hotscripts.com/category/p...code-locators/

Specifically the first few of them, even if you have to pay for them, they look promising.
In any event, it sounds like you'll need to customize anything you decide to use.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•