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?
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
您需要一个经度和纬度的邮政编码数据库 ,您可以从中计算距离。
Google Maps have restrictions in using is for business purposes, so you might want to consider those (restrictions) upfront. From my former experience I would suggest MapQuest API. You can find details here: http://developer.mapquest.com/ and some quick start guide here http://www.mapquest.com/features/developer_tools_oapi_quickstart
MapQuest seams to be better when it comes to commercial deals. Anyway, check their T&C before you will implement it in production.
They have JavaScriopt an I think regular WS for geo-location decoding.
Regards Konrad
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.