CliffCloud / Leaflet.EasyButton

leaflet control buttons with icons and callbacks
http://cliffcloud.github.io/Leaflet.EasyButton/v1/
MIT License
524 stars 123 forks source link

Unable to remove the control - no matter which method is used #63

Closed mm108 closed 7 years ago

mm108 commented 7 years ago

hi,

Thanks for the plugin - quite useful. But I have been running into a problem when trying to remove the control. I have added the control using the sample code in the examples as shown below. But no matter which method I try it will throw one error or the other and I am unable to remove the control. I am using the lastest version of Easybutton and 1.x.x version of leaflet

var coffeeShopMap = L.map('disable-example', {scrollWheelZoom: false})
coffeeShopMap.setView({lat:37.45, lng:-122.17}, 14);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(coffeeShopMap);

var findCoffee = L.easyButton( 'fa-coffee', function(control){
  alert('"expensive query here"');
  /* HERE I INTEND TO REMOVE THE BUTTON, AFTER CARRYING OUT SOME TASKS */
});

findCoffee.addTo(coffeeShopMap);

Now no matter what method I use ( I scoured the internet over this for hours now ), it will not remove the control. I get stack error when I replace 'removeFrom' with 'remove' as explained in other issue / post etc. Any pointers would be greatly helpful. This shouldn't have taken so much time as I am fairly ok with JS.

atstp commented 7 years ago

okay, this is related to another open issue. I'll get it resolved today.

mm108 commented 7 years ago

alrighty thanks :+1:

atstp commented 7 years ago

Could you check if the latest version from npm works for you? (2.2.0)

mm108 commented 7 years ago

Perfect, the latest version from npm works! :100: Thanks a ton