-
Notifications
You must be signed in to change notification settings - Fork 1k
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
layeradd event is not working #647
Comments
Hi, You are right, normal As a workaround, you could simply "patch" the L.MarkerClusterGroup.include({
_originalAddLayer: L.MarkerClusterGroup.prototype.addLayer,
addLayer: function (layer) {
this._originalAddLayer(layer);
return this.fire('layeradd', {layer: layer});
}
}); Demo: https://jsfiddle.net/yez9wn01/8/ It might be more complicated to include it into the plugin, as we would have to wonder what to do when |
@ghybs thanks that's working great. Here is the modified demo: https://jsfiddle.net/n74rayv5/ |
This should be do-able, provided that you rename the alias from Please note that this plugin only works with current stable version of Leaflet (0.7.7), whereas the JSFiddle was built with Leaflet 1.0.0-beta.2. Same with Leaflet.markercluster, make sure you use the appropriate version. |
If this doesn't cause performance troubles then we should probably add the layeradd/remove events. |
Hi, It should be quite straight forward for non-group layers. We could test the performance impact. It would probably simply depend on Leaflet's performance at firing thousands of events. I think the problem is really what to do with Layer Groups: as of today, MCG actually uses only the individual child layers, and discards the parent groups. Stated differently, MCG just transforms groups into arrays. Therefore, Therefore, should MCG fire the The above patch does it the first way. Furthermore, what to do when trying to remove a group? Currently, MCG removes all child non-group layers, even though the group may never have been added itself to MCG. |
Yeah, the group vs child markers is a bit of a weird one. There could be a plugin for MCG that keeps track of the FeatureGroups that are added to extend this functionality (Could also listen for when children are added to these FeatureGroups and add them to the MCG). |
Support for this is in the codebase now. Pretty certain I've covered everything, but there is a chance I've missed something. Please test and give feedback if you have a case that doesn't work correctly. |
… dans un clustergroup cf Leaflet/Leaflet.markercluster#647
… dans un clustergroup cf Leaflet/Leaflet.markercluster#647
Hello,
I wonder how to get the
layeradd
event works for MarkerCluster. For instance, the following code is not working.Is there any workaround to make this works?
The text was updated successfully, but these errors were encountered: