perliedman / leaflet-routing-machine

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

How to show alternatives more then 4 waypoints #678

Open Dostonhack opened 1 year ago

Dostonhack commented 1 year ago

Hi there, I have 4 waypoints, I don't show alternatives and edit alteratives waypoints, pls help me image I have 4 markers that I need to make an alternative to line, similar to yandex this is code image image

curtisy1 commented 1 year ago

By default LRM displays everything that's returned by the routing provider (OSM, Mapbox, etc.), so if only four waypoints are returned, then LRM can't do much about it.

If that's not what you mean, can you share some code so I could try to understand the question a bit better?

Dostonhack commented 1 year ago

thank you for for the answer I have 4 markers that I need to make an alternative to line, similar to yandex

image image

curtisy1 commented 1 year ago

Hey, just wanted to let you know that I'm on vacation so replies might be a bit slower. I'll get back to this as soon as I can, though!

I believe you'll want a custom router or 4 instances of LRM though, from having a quick look. That is, every marker gets its own instance, essentially giving it alternatives as well

curtisy1 commented 1 year ago

Okay, so just to confirm your situation looks like this:

Dostonhack commented 1 year ago

Hi, Sorry, I see now your message, yes it is rigth

curtisy1 commented 1 year ago

That is not currently something that lrm supports. You would have to set up 4 different routing machines with your start, end and marker coordinates as waypoints.

That said, I am happy to accept a pull request that adds an option to make alternatives depend on the closest intermediate waypoint