问题
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!
回答1:
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');
来源:https://stackoverflow.com/questions/41472880/leaflet-sidebar-v2-set-default-to-open