I am using an EasyButton for showing a sidebar in a Leaflet map. Now I want to restrict the functionalities inside the sidebar in that way, that they only are accessible when the sidebar is opened. My plan was to ask for the current state of the easybutton, but I apparently don't know exactly how.
Here the code for the easyButton:
navi_button = L.easyButton({
states:[{
stateName: 'openSidebar',
icon: 'fa fa-route',
title: 'Navigation öffnen',
onClick: function(control){
sidebar.show();
control.state('closeSidebar');
}
},{
stateName: 'closeSidebar',
icon: 'fa fa-route',
title: 'Navigation schließen',
onClick: function(control){
sidebar.hide();
control.state('openSidebar');
}
}]
});
navi_button.addTo(map);
Then it should follow like that (incorrect code):
if (navi_button.state() == openSidebar){
...[sidebar functions]...
}
else{};
Is there a way to get the current state of an easybutton?
control.state()
returns the current state: github.com/CliffCloud/Leaflet.EasyButton/issues/87 – Stefan Jan 3 '19 at 16:18