首页 > 解决方案 > 如何通过单击按钮甚至传单中的标记来制作使我的菜单打开的按钮

问题描述

我正好有这个侧边栏https://turbo87.github.io/sidebar-v2/examples/index.html以及我从该 github https://github.com/Turbo87/sidebar-v2/blob中删除的源代码/master/examples/index.html,正如您在单击标记时看到的那样,它没有执行任何操作,我尝试了多种方式使其在单击标记时打开并带来内容,如果可能的话,请向我显示一个命令通过单击标记使其打开谢谢。

标签: javascriptjqueryhtmlcssleaflet

解决方案


您可以尝试这样的方法来关闭/折叠侧边栏:

function showhidebar(){
button = document.getElementsByClassName('fa fa-bars')[0] 
button.click()
}

map.eachLayer(function(l){if (l instanceof L.Marker) {l.on('click', showhidebar)}});

推荐阅读