Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question 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.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I assumed you looked here first?
    http://www.google.com/search?hl=en&s...script&spell=1

    There are some free zipcode database listings you can download ...
    http://www.google.com/search?hl=en&s...se&btnG=Search

    And finally, Google Maps API:
    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.
    But Google is your real friend for this one.

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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

  • #4
    Regular Coder
    Join Date
    May 2008
    Location
    Oxford, UK
    Posts
    422
    Thanks
    14
    Thanked 27 Times in 27 Posts
    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

  • #5
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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.
    But Google is your real friend for this one.
    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.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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
    •