How do I prevent a page refresh when I click the close button on a leaflet marker?

Viewed 38

Using Angular here. I have a marker on a leaflet map.

const marker = L.marker([34.5, -0.45]).addTo(this.map);
    marker.bindPopup("I'm a marker");

When I go to the map, click this marker and then click the close button, it refreshes the page. I want to disable the redirecting when the close button is pressed so I thought I would try:

marker.addEventListener('click', event => {event.preventDefault();
});

But the property doesn't exist for type LeafletMouseEvent What is the proper way to do this?

0 Answers
Related