PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

BuildPruneCluster cluster/position sometimes gets another cluster or cluster is empty

Open Valachio opened this issue 5 years ago • 0 comments

So I've been noticing that pruneCluster.BuildLeafletCluster = function(cluster, position) {...} does not always return the correct cluster/position. When there are multiple clusters on the map, it sometimes return another cluster.

This happens sporadically. I'd say it happens 1 in 50 or 1 in 100? I tried tracking down the issue but the randomness of its occurrence makes it very difficult.

Can anyone provide some insights as to why this could be happening?

Sample code:

pruneCluster.BuildLeafletCluster = function(cluster, position) {
    let m = new L.Marker(position, {
        icon: pruneCluster.BuildLeafletClusterIcon(cluster)
    });
    m.on('click', function() {
        let markers = cluster.GetClusterMarkers();
    })
    return m;
}

EDIT: I managed to catch one instance of this, where the cluster is empty (even though there is 21 markers in this cluster). console.log shows that the cluster object has these weird properties:

Cluster {
    lastMarker: undefined,
    population: 0,
    _clusterMarkers: Array (0),
    hashCode: 1,
    totalWeight: 0,
    data: {
        _leafletOldPopulation: 16,
        _leafletOldHashCode: 101841549863470
    }
}

EDIT: I correct what I said earlier about it happening randomly. It does not happen randomly and happens to clusters in particular positions. Still trying to figure out the cause.

Valachio avatar Mar 19 '19 18:03 Valachio