Closed koufopoulosf closed 2 years ago
I might not be 100% on point with this, but I think you have a couple of options to achieve the desired result.
routeControl.getPlan()._updateMarkers();
should work fine, since it recreates the markers.spliceWaypoints()
and autoRoute: false
L.Routing.Plan
object and use that to create the markers. This is pretty similar to 1. but you'll have the option of using your own logic in addition to _updateMarkers
. Alternatively, you could also just override _updateMarkers
with your own logic.For a quick rundown of 1. and 2., you can check this fiddle. If those 2 options aren't enough and you need help on getting 3. to work, feel free to ask me anytime
Hello @curtisy1,
Thank you very much for your valuable feedback and the time you devoted to it, I appreciate it!
I tested the fiddle and the first option of using routingControl.getPlan()._updateMarkers();
seems by far the simplest, yet effective way to deal with this issue. However, thanks to the fiddle you provided, I noticed that most of the problem was caused by declaring the variable (e.g. var total_distance
= ...) inside the routesfound
event.
Besides my poor javascript skills, I also tested the fiddle by commenting both routingControl.getPlan()._updateMarkers();
& routingControl.route();
and I could still get updated values on markers, so it makes me wonder whether these are actually necessary for simple scenarios, or they apply on more complex ones.
Thank you once again for your time and for actively maintaining this library.
Hello all,
First of all I'd like to thank the community and especially the contributors for this awesome library!
I would like to display route calculations, on each marker. Suppose we add 3 waypoints A, B and C, then:
However, I could only achieve this result with the following method:
The issue with this solution is that once a new marker is created, calculations are bound to the first
routeControl
instance, thus making the above process, invalid for achieving the desired result.Moreover, the end result should have markers that can move freely around the map and be able to adjust and display their calculations on each marker accordingly.
Any help would be highly appreciated!