perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.06k stars 347 forks source link

Is it possible to pass more than one waypoint ? #704

Open ZeusPod opened 2 months ago

ZeusPod commented 2 months ago

Hello, nice to say hello, more than an error, it is a question. I need to know if it is possible to pass more than 2 waypoints since in the documentation the example only shows 2, and in different tutorials only 2 are passed, I try to pass more than 2 to simulate the route. from a GPS but I get strange behavior, it goes down a street and skirts an entire block, for example

image

curtisy1 commented 2 months ago

Hi @ZeusPod,

You can definitely add more than 2 waypoints. In this example I added three but you could easily add more than that by adding another L.latlng to the array.

That being said, the route does look a little weird. I'm guessing the black markers are the waypoints? In that case it looks like the start waypoint is also the end and the route visits the other waypoints first, going through the smaller streets and then turns around and goes back the main route. Then again, I would have expected it to go back on a highway.

If the problem persists, you would have to show me some of your code or provide a codepen (or similar) so I can have a look.

ZeusPod commented 2 months ago

Hi @curtisy1 Thank you for answering my question. Here I show you a little bit of the code. I applied a reverse to the waypoints and it looks much better since it was bringing me the data in descending order from the database.

image

tvjmohan commented 2 months ago

You can add more....

ZeusPod commented 2 months ago

You can add more....

Thanks so much