SINTEF-9012 / PruneCluster

Fast and realtime marker clustering for Leaflet
MIT License
551 stars 132 forks source link

Open the popup of a marker in the programm #209

Closed mstekker closed 2 years ago

mstekker commented 2 years ago

Hi,

My application needs to programmatically open the popup of a marker. After hours of trying I am stuck. The default Leaflet functions are not working in my code (openPopup, getPopup, ....). The data object also does not contain a reference to the popup.

Does anybody know how to open a popup of a certain marker by code? I could not find a method to access the array with prunecluster markers.

Best regards.

Mart

fungiboletus commented 2 years ago

Hi,

This feature is not implemented. The markers and popups are created on the fly so that's why you cannot find them.

It's not trivial because if you want to open a popup attached to marker, the marker must be displayed. But it's perhaps inside a cluster, and then do you want to disable the clusters or zoom enough to not have a cluster anymore?

You could hack a bit by accessing some private properties on the leaflet map object or prunecluster if you know for sure that it is currently displayed.

In the past, if I wanted to have more interactions with a marker, I was removing/filtering it from prunecluster and adding it again with normal Leaflet methods.

mstekker commented 2 years ago

Hi,

Thx, I will hack around a bit.

Best regards.