问题描述
我有一位客户希望我计算城市之间的距离。我正在做项目在PHP中,JavaScript,我一直在阅读一些长/纬度数据库,但仍然无法找到从哪里开始以及使用它。是否有任何Web服务可以通过传递两个城市名称来查询,并且它可以以英里或公里返回距离?请提供帮助
解决方案我有一位客户希望我计算城市之间的距离。我正在做项目在PHP中,JavaScript,我一直在阅读一些长/纬度数据库,但仍然无法找到从哪里开始以及使用它。是否有任何Web服务可以通过传递两个城市名称来查询,并且它可以以英里或公里返回距离?请提供帮助
解决方案
如果您不 想要维护一个保存纬度/长度到某个地点/城市的GEO数据库,那么您还可以使用Google API来检索地址的坐标:
另一个选择是使用变体如果你不是谷歌粉丝,用Javascript实现的Great Circle Calculator:
i have a client who wants me to calculate the distance in miles between cities. I am doing project in PHP, javascript , i have been reading about some long/ lat database but still not able to find where to start and what to use for it. Is there any web service i can query by passing two city names and it can return me the distance in miles or km? please help
http://code.google.com/apis/maps/documentation/javascript/geometry.html#Distance
If you do not want to maintain a GEO db that maintains the lat/long to a place/city, then you can also use the Google API to retrieve the coordinates for an "address":http://code.google.com/apis/maps/documentation/javascript/services.html#GeocodingRequests
Another option is to use a variation of the Great Circle Calculator implemented in Javascript if you aren't a google fan: http://williams.best.vwh.net/gccalc.htm
这篇关于如何最好地计算两个城市(加拿大)之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!