-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Multi event listeners for plugins development #9917
Comments
Hey @emerciercontexeo thanks for reaching out. Is this an Android plugin? If so, do you know that there is a Mapbox Plugins for Android repo to implement that kind of functionalities? There is where well-contained features (single-purpose libraries) built on top of the Maps SDK live. I encourage you to 👀 it and ask whatever questions you may have there. |
It's an Android plugin. I had already take a look at the Plugins Repositories but I didn't find any example for my issue. On my side, I can imagine two solutions : The first is found in the GeoJSON plugin by passing a Listener to the plugin constructor (or using a setter on the plugin). With this, the plugin can use its own listener, consume it and call the listener provided by the developper. Another solution could be to force the developer to call the plugin listener when he use the same listener in his code. In this case, it have to be well documented to avoid support. But, in my opinion, a plugin should be able to work alone. Without interference with the "standard" mapbox development. If necessary, I can move this discussion to the plugin repository but I think that this should be considered as an improvement of MapboxSDK directly : Provide a way to listen the same event with more than one listener. NB : For camera event, we can use MapView.onChangeListener as a workaround but it's not really friendly. And the problem is still existing for click and annotation listener. |
@emerciercontexeo you are correct that we atm only allow one active listener at the same time. Proposed solution of multiple listeners with |
@emerciercontexeo proposed solution in #10141 |
This landed in #10141 |
@tobrun Thanks for this update. Plugin development is way better. Will you apply the same modification for all the listeners ? For my case, I need this on setOnMarkerClickListener but it should make sense to get it on setOnPolygonClickListener and setOnPolylineClickListener. Thanks again, Etienne |
We like to keep the aim for these to the more low level api's as runtime styling and not expose such mechanisms for higher level api's as annotations. In any case you can roll your own click mechanism relying on MapboxMap#QueryRenderedFeatures without blocking the mentioned listeners. |
I am developing a plugin for mapbox.
The amount of data is huge and I can't just display everything so, to make it works, I have to use the Camera listeners to know what I have to display on the map.
The problem is that if the developer using this plugin wants to listen to Mapbox Camera event, he will destroy my listeners and the plugin won't work anymore.
1- Developer instantiate plugin
2- Plugin internally set camera listener to work
3- Developer set camera listener for his use case
4- Plugin won't work anymore.
Do you have any advise on how to implement this?
Would it require the Mapview to allow multiple listeners (addIdleCameraListener instead of setIdleCameraListener) ?
Thanks,
Etienne
The text was updated successfully, but these errors were encountered: