Leaflet Sidebar V2 set default to open

北城余情 提交于 2019-12-23 20:17:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!