好吧,我正在基于位置的应用程序中工作,我需要在服务器端找到地球上两个位置之间的驾驶距离。我正在用 php 编写 Web 服务。
到目前为止,我可以使用半正弦公式计算空中距离,但现在我想计算行驶距离。
这个问题可能有重复,但我无法找到任何帮助来计算两个“坐标”之间的“行驶距离”,即纬度和经度而不是 PHP 中的地址
Use 谷歌距离矩阵 API https://code.google.com/apis/maps/documentation/distancematrix/ :-
Google 距离矩阵 API 是
提供出行距离的服务
和时间矩阵的起源和
目的地。
这是代码:-
$q = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&mode=driving&sensor=false";
$json = file_get_contents($q);
$details = json_decode($json, TRUE);
echo "<pre>"; print_r($details); echo "</pre>";
欲了解更多信息,请访问谷歌距离矩阵 API https://code.google.com/apis/maps/documentation/distancematrix/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)