apigoogle-mapsmaps

Google Map Directions API Optimize Waypoint and Force Waypoint Order


I am having difficulty in overcoming the situation I am facing. I have a route as follow:

StartPoint

WayPoint A-1 <--- Pickup

WayPoint A-2 <--- Dropoff

WayPoint B-1 <--- Pickup

WayPoint B-2 <--- Dropoff

WayPoint C-1 <--- Pickup

WayPoint C-2 <--- Dropoff

EndPoint

A bus is starting to drive from Start Point and it is supposed to pick 3 passengers up (A, B, C) and drop them off in different locations. The locations are not static and it changes based on passenger.

If I pass all these to google map directions api and set the OptimizeWaypoint option to true the issue that occurs is sometimes the dropoff waypoint occurs before pickup waypoint for a passenger due to route optimization.

Does anyone know a solution to force google map api route optimization to always have pickup before the dropoff for each passenger please?

I appreciate all your help in advance guys.


Solution

  • I have found a solution to my problem after 3 days of research. The solution is not through Google Map API and it's using a third party API called RouteXL. They are providing an API which does such this thing I am looking for. Here is the link to documentation although their documentation is not clearly documented but it has helped me to work it out.

    https://www.routexl.nl/blog/api/?lang=en#post-tour

    The function which I needed was the Tour Post and that does what I exactly needed.

    If anyone needs any help on this I am happy to help.

    I hope this helps everyone else.

    Thank you all for the help.