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

layer.addTo(map) collapses all the groups #61

Closed
dgva opened this issue Jan 13, 2022 · 1 comment
Closed

layer.addTo(map) collapses all the groups #61

dgva opened this issue Jan 13, 2022 · 1 comment

Comments

@dgva
Copy link

dgva commented Jan 13, 2022

Description: I currently have about 5 groups with several layers inside. Anytime I add or remove a layer in the code, using layer.addTo(map) or map.removeLayer(layer) it closes all the groups. This is understandably annoying.

Code example:

const legendGroups = Array.from(document.querySelectorAll(`.leaflet-panel-layers-grouplabel`));

legendGroups.forEach((group) => {

    group.addEventListener('click', () => {
        
        switch (group.innerText) {

            case '-\nLayer1':

                cleanMap();

                map.fitBounds(layer1.getBounds());
                layer1.addTo(map);  /* The layer control collapses when this method executes */

                break;

             case '-\nLayer2':

                cleanMap();

                map.fitBounds(layer2.getBounds());
                layer2.addTo(map);

                break;

        };
    });

});

Edit: This also happens if I try to add any layer manually in the browser console. This really makes it seem that addTo and removeLayer methods are the point of conflict with the plugin.

@stefanocudini
Copy link
Owner

stefanocudini commented Nov 17, 2022

I did some tests and i think it is a problem of L.Control.Layers inherited from L.Control.PanelLayers
unless you have a solution to send in PR I don't think I can solve it in this plugin

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

2 participants