Google 没有路况的地图方向请求

Google Maps direction request without traffic

我必须编写一个程序,告诉我两点之间的最短路线。流量应该不算吧

我的请求是这样的。

'http://maps.googleapis.com/maps/api/directions/json?origin='.$from.'&destination='.$to.'&alternatives=true&sensor=false'

那我这条路走最短路

$data = json_decode(file_get_contents($url))->routes;
usort($data,create_function('$a,$b','return intval($a->legs[0]->distance->value) - intval($b->legs[0]->distance->value);'));
return floatval($data[0]->legs[0]->distance->text);

但这个结果要看实际流量。 如何发送忽略实际流量的请求?

您尝试过使用 Distance Matrix Service 吗?

考虑到 API 文档,这应该是您要查找的内容:

Google's Distance Matrix service computes travel distance and journey duration between multiple origins and destinations using a given mode of travel.

This service does not return detailed route information.

使用此服务时应忽略交通状况。