To show a popup when clicking the map, I entered:
const popup = function(e){new maplibregl.Popup().setLngLat(e.lngLat).setHTML('MODIFICATIONS').addTo(map)}; map.on('click', popup); map.on('ClosePopups', popup.remove()); Why doesn't it work?
If the .addTo(map) is included at the end of the const, and removed from the map.on, the popup does appear OK.
In either way, the popup is NOT removed programmaticaly when the 'ClosePopups' button is activated. map.fire(ClosePopups);