mapbox / mapbox-gl-directions

Directions plugin for mapbox-gl-js using Mapbox Directions API.
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
ISC License
237 stars 125 forks source link

Fix bug where re-adding component on style change fails #236

Open jonathonwpowell opened 4 years ago

jonathonwpowell commented 4 years ago

The goal of this PR is to fix #190

Currently if a user of Mapbox GL JS is using this component and they want to switch styles, they need to remove and re-add the directions component. But due to how the onAdd function works, it will not trigger the re-addition of some styles, as it will wait for a load event that will never come. Instead this subscribes to the idle event and then unsubscribes itself once it has triggered.

Please let me know if I can improve the PR in any way :)

xiaofanliang commented 1 year ago

Any updates on this fix?