I need a "find nearest location" on our website.
Where visitor enters their zip/postal code, then they are redirected to specific webpage for our nearest location. We have forty USA and Canada locations.
How can I build something like this? Could I do this with the Google Maps API? I already have a custom map on Google Maps. It's plotted with our locations. It would be nice to send Google Maps a command to say "what's our nearest location at ________ zip code".
Any suggestions?
This ZIP Codes on Google Maps tool will show all ZIP Code boundaries, in the U.S. anyway. To see ZIP Codes for a specific city, address, etc, just type the city or address in the "Search places" box just above the map.
ZIP code lookup The request format is: http://maps.googleapis.com/maps/api/geocode/json?address=ZIP_CODE&key=YOUR_API_KEY will, and in the response you get a lot of information, including for our purposes, that 92101 is the postal code for San Diego, California.
if you have the longitudes and latitudes of each zipcode (search google) you can use the Haversine Formula to calculate nearest neighbours.
http://www.codecodex.com/wiki/Calculate_Distance_Between_Two_Points_on_a_Globe
You need a database of zip codes with longitude and latitude, from which you can calculate the distance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With