I need to get the shortest route with several waypoints A, B, C, D. So I need the shortest route from A to B, the shortest from B to C and so on. The way I understand is that the API should give me a few alternate routes from A to B, a few alternate routes from B to C... And at the end, I should go through all the leg and choose the shortest one.
But Google Direction API gives me only one route as a response. But if I ask the route from A to B, it returns 3 alternate routes, the same from B to C, etc.
My code:
directionsService.route({
origin: 'A',
destination: 'D',
waypoints: [
{
location: 'B',
stopover: true
},
{
location: 'C',
stopover: true
}],
travelMode: 'DRIVING'
, provideRouteAlternatives: true
}, callback);
the response I get is this click to see image
I also tried using stopover: false and got the same result. I cannot use travelMode: 'WALKING' as the distance would be very different.
How can I solve this?