嘿,我在php中的谷歌地图代码适用于除公交模式以外的所有其他旅行模式(驾驶,步行,骑自行车)。我在计算到达目的地所需的时间时发现了错误.我在PHP中的代码:
<?php
$infos = json_decode(file_get_contents('http://maps.googleapis.com/maps/api/distancematrix/json?origins=Guildford,+Surrey&destinations=Embankment,+London&mode=walking'));
print_r($infos->rows[0]->elements[0]->duration);
?>
请帮助我,我的朋友。
Google Distance Matrix API 中没有transit
模式。
mode
— 指定计算方向时要使用的运输方式。有效值为:
driving
(默认值)指示使用道路网络的标准行车方向。
walking
要求通过人行道和人行道(如果有)提供步行路线。
bicycling
通过自行车道和首选街道(目前仅在美国和加拿大一些城市提供)请求自行车路线。
https://developers.google.com/maps/documentation/distancematrix/#DistanceMatrixRequests