Multiple destinations and one source

I am developing my thesis project for my final Master year in college.
The concept is about smart waste management, I already have a function that assigns bins to workers so that each worker has to pickup certain number of garbage bins.

After implementing a code and reading the documentation, I found out that the route is only for 2 markers on the map.

I am using Leaflet map by the way. Does OpenRoute service allows for multiple destination?

My only purpose is to let the driver know which bin he should start with then the 2nd, the 3rd etc …

Could someone help me with the correct documentation if this is feasible?

Hi @elissasaliba,

If you use the POST endpoint:
https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/post

You can do up to 50 locations in one directions request.

Best regards

Hi @amandus ,
Thank you for your reply!

I did implement this POST method and I am able to read the API response successfully with a response code = 200.
However, I couldn’t find any documentation on how to draw the route on Leaflet map.
Could you please provide me with Javascript examples if any?

Thank you

Hey @elissasaliba,

ah, i Missed the Leaflet part last time.
In that case you might want to use the geojson endpoint.
Examples for drawing geojson on a leaflet map can be found in the leaflet documentation.
If you need more fine-tuning for displaying the route, you could also programmatically convert the response coordinates to PolyLines as needed.
You can also take a look at the dev app in our JS package, to get some ideas (uses Leaflet wrapper for VueJs).

Best regards

Hello @amandus !

The implementation was successful after using GeoJSON format.

Thank you!

1 Like