I just recently began a project for a client that will require a proximity search feature. Basically the visitor inputs their location, either city/state combo or zip code along with a proximity value (within 10 miles, 25 miles, 50 miles etc) and the search returns a list of businesses (in this case distributors of the clients product line) within that area. I’ve seen these types of searches many times, but this is the first time I’ve had occasion to build one.
To even begin a project like this you would generally need to get your hands on some kind of database mapping city/states and zip codes to latitude and longitude values before you could even start wondering how to calculate a radial distance area from those locations. Traditionally when it comes to these databases, you can either buy the data which is usually a little pricey and may carry a monthly subscription fee as well. Or you can dig around various federal government websites looking for the data only to find it 5 or 6 years out of date and compiled in way that isn’t quite what you wanted. Frankly, either option kinda sucks. Thankfully we now have very sophisticated mapping services from Google, Yahoo and Mapquest that can be leveraged for the task of geocoding locations.