Using sheetlet.js, how can I iterate over tokens in a cluster?

We have a map, and at a certain level of scaling, we begin to clustering markers.

Now I want to be able to delete certain markers. I can remove tokens that are not involved in the cluster, but tokens in the cluster are not deleted because the code does not iterate over them.

I would post the code, but it's everywhere and pretty specific.

I can do the following:

$.each(MAP._layers, function (i, layer) {
    if (layer.feature) {
        var marker = LIGHTWEIGHT_BUILDING_MAPPING[layer.feature.id];
        MAP.removeLayer(marker);
    }
});

And all visible tokens are deleted, but not those that are inside the cluster. Any thoughts?

+4
source share
1 answer

You cannot iterate over markers on a map or cluster.

Create an array into which you click markers when they are created.

Iterate through an array

,

if(cluster.hasLayer(marker) cluster.removeLayer(marker);
if(map.hasLayer(marker) map.removeLayer(marker);
// remove marker from array (easier with a jQuery Array)
+4

Source: https://habr.com/ru/post/1548579/


All Articles