Reputation: 347
I want to listen to spiderfied and unspiderfied events on the cluster group. These events are described here. I have the following code and I am not able to listen to the events.Plese help.
var markerGroup = L.markerClusterGroup();
//adding markers to markerGroup
// ...
markerGroup.on('spiderfied', function (a) {
// a.layer is actually a cluster
console.log('cluster ' + a.layer.getAllChildMarkers().length);
});
markerGroup.on('clusterspiderfied', function (a) {
// a.layer is actually a cluster
console.log('cluster ' + a.layer.getAllChildMarkers().length);
});
edit: added fiddle
Upvotes: 3
Views: 2011
Reputation: 53185
You correctly attach a listener to the Marker Cluster Group "spiderfied"
event, but there is no layer
attribute to the event argument.
As stated in the documentation:
Contains
cluster
andmarkers
attributes
Live demo: http://plnkr.co/edit/BgzBDbLY7oPEW98jaNiX?p=preview
Upvotes: 3