Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
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

Description

@luukrijnbende

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions