Avoid Some Coordinates In Routes Using Google Directions Api Android
Solution 1:
The question is not very clear, but I would try to provide a better approach to deal with such situations.
Since waypoints are specified within the waypoints parameters and can consist of one or more address, I would recommend using a name instead of the geocoordinates separated by pipe (|). This would indeed reduce the risk of getting faulty results.
On the top of it you can put optimize:true as the first argument within the waypoints parameter to allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order.
Here is an example.
https://maps.googleapis.com/maps/api/directions/json?origin=Adelaide,SA&destination=Adelaide,SA&waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA&key=API_KEY
For more details please refer to this official Google documentation.
Solution 2:
Google maps doesn't support this feature yet and there are some requests to add it but there is another way to perform this with here maps.
https://developer.here.com/documentation/routing/topics/example-route-avoiding-an-area.html
Post a Comment for "Avoid Some Coordinates In Routes Using Google Directions Api Android"