I am using the example at the link https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/ to show results from the Mapbox Directions API. The problem arises when creating two maps and attaching mapbox-gl-directions plugins to them. Example link: https://jsfiddle.net/kajwuoz8/. When I choose a route on one map, the same route also appears on the other map without my interaction. What can I do to make the maps independent of each other ? How to make it possible to select one route on one map and another route on second map ?

  • This is a bug in mapbox-gl-directions, it might be how it uses Redux to manage state, which incorrectly get's shared across instances. I'd recommend opening an issue at github.com/mapbox/mapbox-gl-directions/issues, if you manage to fix this please open a PR. – AndrewHarvey Sep 20 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.