Reputation: 325
I'm creating a mapbox plugin that should update when a layer is added or removed. There are events for style and source adding, but none for layer.
My current solution is to programatically fire custom events after adding or removing layers that are listened inside the plugin, but this of course happens outside the scope of the plugin and it's not an appropriate solution.
What would be the best approach to handle this?
Upvotes: 0
Views: 518
Reputation: 126045
Listen to the styledata
events. It gets called any time a layer is added or removed. You might have to keep track of which layers were present beforehand to know if that change specifically has occurred.
Upvotes: 1