如何获得谷歌Directions API的最短路线,而不是最快? [英] How to get shortest route in google Directions API instead of Fastest?

查看:281
本文介绍了如何获得谷歌Directions API的最短路线,而不是最快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制包含航点的起点和目的地的路线。当我将优化参数设置为true时,它会以最快而非最短的形式返回结果。我尝试了其他选择:真实但没有改变,

请求是这样的: -
检查此链接

请注意,我正在为android工作,所以会正在使用Android Api V2。任何帮助都是可以接受的。

解决方案

不幸的是,目前还没有办法让API在所有API中返回绝对最短的路由的情况。

您必须获得较短路线而不是最快路线的一个选项是让API使用alternatives选项返回替代路线[1]。然后您可以检查结果并选择距离最短的一个。这可能不会提供绝对最短的路线,但会给你一个从中选择最短路线的列表。

[1] https ://developers.google.com/maps/documentation/directions/intro#RequestParameters



我希望这些信息能够回答您的问题。

I'm trying to Draw a route with origin and destinations including Waypoints. When I set optimized parameter as true, it returns me the result in form of fastest instead of shortest. I tried alternatives:true but no change in response,

Request is like this:- Check this link

Kindly note that am working for android so will be using Android Api V2. Any help would be appreciable.

解决方案

Unfortunately, there is not currently a way to have the API return the absolute shortest route in all situations.

One option you have to get shorter routes rather than the fastest route is to have the API return alternative routes with the alternatives parameter, [1]. You can then examine the results and select the one with the shortest distance. This may not provide the absolute shortest route, but will give you a list of possible routes from which to select the shortest.

[1] https://developers.google.com/maps/documentation/directions/intro#RequestParameters

I hope this information answers your question.

这篇关于如何获得谷歌Directions API的最短路线,而不是最快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆