Office Locator

Discussion in 'Programming' started by crazyFoo, Jun 20, 2008.

  1. #1
    We have multiple offices around our state, and I'm creating an office locator tool that will help people find the nearest office when they enter a zip code. I'm having a hard time wrapping my brain around the logic I need to use. Here is what I have come up with:

    1-Calculate the Longitude and Latitude of all of our offices, and store it in a database.
    2-Calculate the longitude and latitude of the center of the zip code entered.
    3-Subtract the longitude of the zip from the longitude of the offices.
    4-Subtract the difference between the latitude of the zip from the latitude of the offices.
    5-Add the 2 differences together, an organize them in an ascending order.
    6-Output the list of offices with the closest one to the top.

    Is this the best logic for an office locator? Can I get the longitudes and latitudes from something online like the Google Maps API?

    Any other suggestions would be very helpful.
     
    crazyFoo, Jun 20, 2008 IP