Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Popup closes when changing marker icon #358

Open
luukrijnbende opened this issue Aug 3, 2018 · 0 comments
Open

Popup closes when changing marker icon #358

luukrijnbende opened this issue Aug 3, 2018 · 0 comments

Comments

@luukrijnbende
Copy link

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant