Skip to content
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

How to remove layer from group dynamically? #65

Open
scarybook opened this issue Feb 16, 2023 · 0 comments
Open

How to remove layer from group dynamically? #65

scarybook opened this issue Feb 16, 2023 · 0 comments

Comments

@scarybook
Copy link

scarybook commented Feb 16, 2023

I have noticed that both methods below only works when layer is added to a map directly and not to a group

panelLayers.removeLayer(toRemove)
or
toRemove.removeFrom(maps[mapId])

function addLayer(mapId, layer, layerId) {
    layer.id = layerId;
    layers[mapId].push(layer);
    layer.addTo(maps[mapId]);
}

function addLayerToGroup(groupId, layer, layerId) {
    layer.id = layerId;
    for (var i = 0; i < panelLayers._layers.length; i++) {
        if (panelLayers._layers[i].id == groupId) {
            layers[mapId].push(layer);
            panelLayers._layers[i].layer.addLayer(layer);
        }
    }
}

How to properly remove layer from the map when layer is in a group?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant