1

Is there a function that I can call to close all open popups in the angular-leaflet directive? Working from the jQuery suggestion from here I have tried the following:

document.getElementsByClassName('.leaflet-popup-close-button').click();

but I get

TypeError: undefined is not a function

alternatively, I have tried:

document.getElementsByClassName('.leaflet-popup-close-button')[0].click();

but that does not work either:

TypeError: Cannot read property 'click' of undefined
David
  • 9,635
  • 5
  • 62
  • 68
Tony Laidig
  • 1,048
  • 2
  • 11
  • 33

1 Answers1

2

Looking through the original Leaflet docs, the solution is to get the native Leaflet map object and call functions on that.

            leafletData.getMap().then(function(map) {
                map.closePopup();
            });
Tony Laidig
  • 1,048
  • 2
  • 11
  • 33