ui-leaflet icon indicating copy to clipboard operation
ui-leaflet copied to clipboard

Popup closes when changing marker icon

Open luukrijnbende opened this issue 7 years ago • 0 comments

Hi,

When I update the icon of a (div) marker as follows:

_marker.icon.html = "some html";

The popup, if open, closes. This makes the popup unusable if the icon changes every few seconds.

I've tracked the problem down to the following code on line 2361 of ui-leaflet.js:

marker.closePopup();
marker.unbindPopup();
if (isString(markerData.message)) {
    marker.bindPopup(markerData.message, markerData.popupOptions);
    // if marker has been already focused, reopen popup
    if (map.hasLayer(marker) && markerData.focus === true) {
        marker.openPopup();
    }
}

When I comment this code the popup stays open when changing the icon. Is there any way to prevent the popup from closing? If not, I propose to add some kind of flag to the marker defining if the popup should close on icon change. Something like:

_marker = {
    ...
    closePopupOnIconChange: false
    ...
}

or

_marker = {
    ...
    popupOptions: {
        closeOnIconChange: false
    }
    ...
}

Thanks!

luukrijnbende avatar Aug 03 '18 12:08 luukrijnbende