Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to edit routes once they have been found? #693

Open
benzene29 opened this issue Sep 14, 2023 · 2 comments
Open

Is it possible to edit routes once they have been found? #693

benzene29 opened this issue Sep 14, 2023 · 2 comments
Labels

Comments

@benzene29
Copy link

Hi,
I am currently working on a university project where we are creating an application that includes routing as one of its features. I was wondering if it is possible to access the array of coordinates inside the selected route and then selectively change them?

Any help would be much appreciated, thank you.

@peter1599
Copy link

Also curios if its possible in some way. Tried with _selectedRoute but sadly not working.

I really need to change the route manually.

@curtisy1
Copy link
Collaborator

Apologies for the late reply @benzene29 and @peter1599

That's an excellent question and I don't think it's currently possible with the built-in functionality of LRM.

However, as @peter1599 said, _selectedRoute should work, in theory, as long as you set it again after (since Leaflet doesn't support on the fly updates, so we need to trigger an update internally).

This is done by the _updateLine function, which in turn gets called when either a route is selected, or alternatives are set.
As such, you can update the route by retriggering the _routeSelected or setAlternative functions.

For a working example, see this fiddle (note, you need to press the button in the bottom left corner twice for it to work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants