Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaflet Sidebar V2 set default to open

I'm using Leaflet's Sidebar V2 plugin and it's working great, but I would like to have it open by default. So when the page loads, the sidebar is open but can be collapsed rather than the other way around. Is there a way this can be done?

Thank you in advance!

like image 417
Heather Avatar asked Jun 10 '26 13:06

Heather


1 Answers

Just after you add the sidebar to the map, use the method open().

The argument of the method is the name of the tab.

var sidebar = L.control.sidebar('sidebar').addTo(map);

sidebar.open('home');
like image 66
YaFred Avatar answered Jun 12 '26 04:06

YaFred



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!