unbam / Leaflet.SlideMenu

A simple slide menu for Leaflet.
BSD 2-Clause "Simplified" License
58 stars 19 forks source link

How to trigger slidemenu to open? #6

Closed habib-farhan closed 3 years ago

habib-farhan commented 6 years ago

Is there a way to trigger the slidemenu and open without having to click on the burger menu? I some buttons on the map and when i click on those i want my slide menu to open. Please drop a tip, how to do that.

liuchuancong commented 5 years ago

@habib-farhan first

var container;
L.Control.SlideMenu = L.Control.extend({

next add method

toggle(){
        container = document.getElementsByClassName('leaflet-menu')[0];
        container.style.display = 'none';
    },

next update

.on(link, 'click', function(){
                // Open
                container = document.getElementsByClassName('leaflet-menu')[0];
                container.style.display = 'inherit';
                this._animate(this._menu, frominit, 0, true, ispx, unit);
            }, this)

You can add yours animation!

liuchuancong commented 5 years ago
L.control.slideMenu().toggle()