Closed mpbotti closed 6 years ago
If you just want to use the Control.Layers.Tree, start it with the option collapsed: false
.
Something like L.control.layers.tree(baseTree, null, {collapsed: false}).addTo(map);
If you want to create your own Control, you have to extend the the options with the default value.
Thanks for your answer Javier. Sadly, the code does not works as it supposed to do it. I've typed it as you say, but have had no effect at all. I've also modified the .js file a little bit adding "collapsed: false" to the options statement but none of this make any change... Thanks anyway! Regards, M.
I did in this fiddle, and it works (a copy of basic.html, just adding this option) https://jsfiddle.net/fkd7ecc9/ Could you show us an example?
Hi Javier! Thanks for your answer, and my apologies for my late on this one... So, here is the thing:
Following your example, I've created a piece of my webpage in jsfiddle, using the leaflet libraries I'm trying to merge (lealfet, layers tree and sidebar v2, among others...). It was a nice exercise although a bit frustrating, specially when I realized jsfiddle didn't saved my work automatically and I losted four hours in a row coding! Part of the learning curve I guess... anyway I have to admit that jsfiddle is a nice piece of software!
Ok, so, once I had all working in jsfiddle I tried to made the same with my original code, and had found it wasnt working (layers tree appears inside sidebar pane but collapsed... no mater how many "collapsed: false" declarations I had included in my code!...). To make a long story short; after chopping out pieces of code I found that layers tree and David Chouse´s navbar (https://github.com/davidchouse/Leaflet.NavBar) used the same "options" variable declaration (I cant include NavBar in my example, cause I cant found a working library for jsfiddle, only github, sorry...).
So, the solution I've found was to rename one of the "options" declaration to "options2" (clever right ;)) and voila! Now I have an expanded layers tree inside sidebar. My next step is to turn off the surrounding box around layers tree, or at least make it invisible, but I cant found the correct CSS definition. I´ll see how I can accomplish this...
Here is my jsfiddle example... https://jsfiddle.net/mbotti/z3f4x0w7/
Regards, M.
Great that you get it. Using the Chrome "Developer Tools" you get easily to this CSS definition (line 449 of css file):
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
I understand that I can close the issue.
Thanks again Javier for your kindly help! You can close this issue. Regards, M.
Hi Javier, I want to use your control with the Layer Icon expanded by default (without the need to hover the mouse over it to see layers). I think I need to include something like this: L.control.extend({ options: { collapsed: false }}) but I have no clue how to add it to your code. Could you give me a hand with this? This is what I want to see when I open my toolbar...
Thank you in advance for your help!