gpt4 book ai didi

javascript - Google Maps v3 DistanceMatrix/Directions 忽略 avoidTolls :false

转载 作者:行者123 更新时间:2023-11-30 12:54:14 33 4
gpt4 key购买 nike

我尝试找到从加利福尼亚州孤松镇加利福尼亚州优胜美地村的最短路线。

一个简单的谷歌地图查找显示两条路线:

  1. 收费路线:US-395N、CA-120W ~316 公里
  2. 无收费路线:CA-99N ~596 公里

DirectionService/DistanceMatrixService 有一个 avoidTolls 参数:

avoidTolls (optional) — If true, the directions between points will be calculated using non-toll routes, wherever possible.
avoidTolls (optional) when set to true indicates that the calculated route(s) should avoid toll roads, if possible.

我希望服务在应用 avoidTolls: false 时返回路线 #1,但返回路线 #2。

是我的期望还是我的实现http://jsfiddle.net/nQzD8/2有缺陷?

更新:

作为博士。 Molle 指出,路线 #1 被忽略不是因为包括收费路线,而是因为它可能在当前时间关闭(“这条路可能季节性关闭。”在方向步骤中)。

user2961817发现,316km的结果可以通过避开Highways(设置avoidHighways: true)获得。

除了成为 Maps for Business 客户并使用带有 departure_time 参数的 DistanceMatrix API 之外,是否还有其他选项可以检索一年中其他时间的 DistanceMatrix 结果?

解决方案:

路线 #1 被忽略,因为它可能在请求时关闭,而不是因为包含收费路线。为了检索更短的路线,有以下选项:

距离矩阵服务:

  • 成为企业客户并设置 departure_time 参数。
  • 使用 avoidHighways: true 发出第二个请求并取较短的路线(碰巧在这种特殊情况下有效,但在大多数情况下不会其他情况)

方向服务:

  • 使用 provideRouteAlternatives:true,迭代备选方案和取最短的一个

最佳答案

当我通过 CA-120 W 明确绘制方向时,我得到了这条路的以下信息:This road may be seasonal closed 。也许这就是谷歌避开这条路的原因。

The Tioga Road closes due to snow, usually from sometime in November through late May or early June. ...现在是十一月

关于javascript - Google Maps v3 DistanceMatrix/Directions 忽略 avoidTolls :false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19819586/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com