Reputation: 328
I'm using Direction API to display the routes between source and destination. I formed the URL like this
it is giving "multiple routes" like this
`{"routes" :
[
{ }
{ }
{ }
]}`
but when i add the waypoints in the URL
it is giving "single route" like this
`{
"routes" :
[{
"legs" : [ { }, { } ]
}]
}`
I specified the waypoint near to the starting location, still am getting single route only.
is there any mistake in my URL or it's direction API nature ??
Anyone faced this issue??
Upvotes: 2
Views: 2037
Reputation: 763
The docs may have changed from the time this question was posted. But now (in 2021) they are clear:
waypoints
:
... Waypoints alter a route by directing it through the specified location(s)...
alternatives
:
... This is only available for requests without intermediate waypoints.
So, yes, if you use waypoints
you will get just one route, regardless of the alternatives
prop's value.
Upvotes: 0
Reputation: 4051
According to this article
Generally, only one entry in the routes array is returned for directions lookups, though the Directions service may return several routes if you pass alternatives=true.
So there is no guarantee that will get some alternative routes if you added alternatives=true
Upvotes: 2