php 按邮政编码“查找最近的位置”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2510514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Find nearest location" by Zip/Postal Code?
提问by codemonkey613
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".
我怎样才能建立这样的东西?我可以用 Google Maps API 做到这一点吗?我已经在谷歌地图上有一个自定义地图。它与我们的位置一起绘制。最好向 Google 地图发送一条命令,说“我们在 ________ 邮政编码处最近的位置是什么”。
Any suggestions?
有什么建议?
回答by Jon Black
if you have the longitudes and latitudes of each zipcode (search google) you can use the Haversine Formula to calculate nearest neighbours.
如果您有每个邮政编码的经度和纬度(搜索谷歌),您可以使用 Haversine 公式来计算最近的邻居。
http://www.codecodex.com/wiki/Calculate_Distance_Between_Two_Points_on_a_Globe
http://www.codecodex.com/wiki/Calculate_Distance_Between_Two_Points_on_a_Globe
回答by mikerobi
回答by Konrad
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
出于商业目的使用 Google 地图有限制,因此您可能需要预先考虑这些(限制)。根据我以前的经验,我建议使用 MapQuest API。您可以在此处找到详细信息:http: //developer.mapquest.com/和一些快速入门指南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.
MapQuest 在商业交易方面做得更好。无论如何,在生产中实施之前,请检查他们的 T&C。
They have JavaScriopt an I think regular WS for geo-location decoding.
他们有 JavaScriopt 和我认为用于地理位置解码的常规 WS。
Regards Konrad
问候康拉德

