【问题标题】:how to get multiple driving route results for single destination from google api call?如何从谷歌 api 调用中获取单个目的地的多条驾驶路线结果?
【发布时间】:2013-01-05 01:29:33
【问题描述】:

我正在向 google API 发送 curl 调用以获取两点之间的行驶距离。但是,它给了我最短驾驶时间的路线,而不是我正在寻找的最短驾驶距离路线。当我在带有谷歌地图的浏览器中拨打电话时,插入经纬度,我得到 3 条不同的路线。第二条路线是我正在寻找的路线,但 API 调用只返回距离更长但时间更短的第一条路线。

我在 API 文档中看到有一个名为“alternatives”的参数,但它似乎对我的调用没有任何影响。这是我要调用的 URL:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=46.839382,-100.771373&destinations=46.791115,-100.763650&sensor=false&alternatives=true&units=imperial

【问题讨论】:

    标签: distance


    【解决方案1】:

    好的,想通了。问题是我需要使用方向 api,而不是距离矩阵 api。然后解析出最短距离。

    http://maps.googleapis.com/maps/api/directions/json?origin=46.839382,-100.771373&destination=46.791115,-100.763650&units=imperial&alternatives=true&sensor=false

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-26
      • 1970-01-01
      相关资源
      最近更新 更多