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

expanded: true opens all groups #15

Open
letmaik opened this issue Oct 30, 2015 · 4 comments
Open

expanded: true opens all groups #15

letmaik opened this issue Oct 30, 2015 · 4 comments

Comments

@letmaik
Copy link

letmaik commented Oct 30, 2015

When I add a layer to a group (or implicitly create a new group), I want that group to be expanded, but not the other groups. When I set expanded: true in the options for addOverlay it opens all groups which I think is a bug.

@stretchkerr
Copy link

Do it this way instead:

var baseLayers = [
{
groupName : "Base Maps",
expanded : true,
layers : {
"LINZ Aerials": aerials,
"Topo50": topo50,
"OpenStreetMap": osm,
"Google Terrain": gTerrain,
"Google Hybrid": gHybrid
}
}
];

        var overlays = [
                        {
                            groupName : "Species Distribution",
                            layers    : { 
                                        "Feral Pig 2007": pigs,
                                                        "Feral Goat 2007": goats,
                                                        "Fallow Deer 2007": fallow,
                                                        "Red Deer 2007": red,
                                                        }   
                                                     }, {
                            groupName : "Points of Interest",
                            expanded : true,
                            layers    : { 
                                        "DOC Campsites": campsites,
                                                        "DOC Huts": huts        
                                            }   
                                                     }                       
        ];

This makes the Basemaps layer group expanded by default. Species Distribution overlay group is collapsed by default, and Points of Interest overlay group is expanded by default.

Check out my example:
https://dl.dropboxusercontent.com/u/7075784/Leaflet/Leaflet2.html

@letmaik
Copy link
Author

letmaik commented Oct 30, 2015

I'm not sure how this solves my problem. Maybe I wasn't precise enough, but this happens when I'm dynamically adding groups and layers, not when I initialize the control. When I dynamically add a new group with expanded: true then it also expands all other groups. But I want the existing groups to stay in whichever state they are.

@davicustodio
Copy link
Owner

@neothemachine I understand the problem. Really I did not write the ability to expand a group dynamically. I am currently struggling to find time to update the plugin, but if you are willing to look at the code and create a pull request ...

@davicustodio
Copy link
Owner

@stretchkerr I enjoyed its application in https://dl.dropboxusercontent.com/u/7075784/Leaflet/Leaflet2.html
I realized that their implementation is still a problem (I just load the last commit) related to the automatic resizing of the control relative to the main application window.

Taking advantage of you is already with that application in a production environment? If so, you could share the link?

Thank you.

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

3 participants