-
Notifications
You must be signed in to change notification settings - Fork 130
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
setOrigin and setDestination changing others maps directions #170
Comments
Problem is also present on drawn routes. I need to removeRoutes() on a new MapboxDirections to prevent it using other map's directions. And redraw it every time. |
thanks for the report @aless673! can you please include a self-contained, minimal example of what you're seeing on jsbin or jsfiddle? it will be very helpful in diagnosing and fixing the problem! |
Hi, Here the demo : https://stackblitz.com/edit/ionic-vpnvwf?file=pages/home/home.ts You can click on the init maps button and then play with Change directions buttons. You will see that directions are impacted on both maps |
thanks for the demo app, but in order to ensure the problem is with this repository, and not another framework, it would be very helpful to see a minimal reproduction without third-party libraries or frameworks. |
Hi, Here a framework-less example : https://jsfiddle.net/4cxrd18d/ |
thank you! we'll look into this when we get a chance but if this is urgent for you, we'd welcome a PR implementing a fix. |
Hi, I tried resetting the origin and destination, but somehow the fields are not taking it also |
Hi there 👋 I've got the same issue. My guess is that the plugin is using a singleton to store the data which is why it updates everywhere no matter the instance of Is there a quick way we can refactor that singleton to spin up a new unique store for each instance? |
Digging through the code confirmed my hypothesis. mapbox-gl-directions/src/directions.js Lines 7 to 8 in 933bf6d
If we moved these two lines in the constructor and updated all references of Unfortunately, this is for work and I can't spend too much time on this but I might make a quick PR during my free time if no one has done one by then. |
Hi, any updates on this issue? Thank you very much. |
Hi,
I have 2 classes with 2 differents maps with differents containers.
When i made changes on one map, this is independant from the other map, excepts for setOrigin and setDestination. Those 2 functions impacts the two independants directions instances.
Class 1
Class 2
Problem : the setOrigin and setDestination from directions2 impacts the direction1 instance.
The text was updated successfully, but these errors were encountered: