带有航点的当前交通中的Google Maps Directions [英] Google Maps Directions in current traffic with waypoints
问题描述
我正在使用google maps api来获取带有durationInTraffic选项的路线.
I am using the google maps api to get directions with the durationInTraffic option.
var request = {
origin: start_address,
destination: end_address,
waypoints: waypts,
durationInTraffic: true,
optimizeWaypoints: true,
travelMode: tmode
};
directionsService.route(request, function(response, status) { ....
这在没有起点的开始和结束地址的情况下都可以正常工作,如下所示:
This is working fine with a start and end address with no waypoints, as seen below:
我的问题是,当我添加航路点以进行路由时,当前交通时间"估算值将不再显示.
My problem is that when i add a waypoint to to route then the "time in current traffic" estimate is no longer shown.
这是否是API的限制(我没有找到支持该文档的文档)?或者可能的解决方法/变通方法,因为路况信息对我的应用非常重要.
Is this a limitation of the API (I have found no documentation supporting that)? Or a possible fix / workaround as the traffic information is very important to my app.
推荐答案
我向Google员工问了类似的问题,这是否是因为我在航路点上使用了stopover = true选项,确实如此.如果将其stopoverover设置为false,则应返回流量的持续时间.
I asked a similar question to the folks at Google about whether this was because I was using the stopover = true option in the waypoints and indeed it was. If you set it stopover to false, the duration in traffic should be returned.
在当前文档中此处
来自Google:
...我们无法预测您将停留多长时间中途停留,因此很难对duration_in_traffic.通过使用非中途停留点,您可以声明您将不会在这些路口停留,从而使我们的服务能够估计每条腿的duration_in_traffic.
... we can't predict how long you will stop at stopovers, making it difficult to give a proper estimation for the duration_in_traffic. By using non stopover waypoints you state that you wont stop at those waypoints, thus allowing our service to estimate the duration_in_traffic of every legs.
他们还提到,如果您使用Directions Matrix API,则只有起点/终点对才计入您的配额,因此您可以发送多个请求而不会受到额外的惩罚.
Also, they mentioned that if your using the Directions Matrix API, only origin/destination pairs count against your quota, so you can send multiple request without additional penalty.
这篇关于带有航点的当前交通中的Google Maps Directions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!