如何使用传单markercluster spiderfied事件
how to use leaflet markercluster spiderfied event
我想收听群集组上的蜘蛛化和非蜘蛛化事件。这些事件被描述为 here。
我有以下代码,但无法收听 events.Plese 帮助。
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);
});
编辑:添加了 fiddle
您正确地将侦听器附加到标记群集组 "spiderfied"
事件,但事件参数没有 layer
属性。
如文档中所述:
Contains cluster
and markers
attributes
我想收听群集组上的蜘蛛化和非蜘蛛化事件。这些事件被描述为 here。 我有以下代码,但无法收听 events.Plese 帮助。
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);
});
编辑:添加了 fiddle
您正确地将侦听器附加到标记群集组 "spiderfied"
事件,但事件参数没有 layer
属性。
如文档中所述:
Contains
cluster
andmarkers
attributes