I want to determine the shortest path that includes several waypoints such as A, B, C, and D. Essentially, I’m looking for the shortest path from A to B, then B to C, and finally C to D. I understand that the API should provide multiple routes from A to B, and similarly for B to C and C to D. However, the Google Directions API only gives me a single route in response. When I independently request the route from A to B, I do get three alternative routes. Here’s my current code:
directionsService.route({
origin: 'A',
destination: 'D',
waypoints: [
{
location: 'B',
stopover: true
},
{
location: 'C',
stopover: true
}],
travelMode: 'DRIVING',
provideRouteAlternatives: true
}, callback);
I’ve tried setting stopover: false
but still get the same result. I cannot use travelMode: ‘WALKING’ due to significant distance differences. Any suggestions on resolving this?