How to get shortest route in google Directions API instead of Fastest? [duplicate]

烈酒焚心 提交于 2020-06-18 11:28:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/37783235/how-to-get-shortest-route-in-google-directions-api-instead-of-fastest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!