SINTEF-9012 / PruneCluster

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

Adding tooltip to markers #134

Closed axelerate closed 7 years ago

axelerate commented 7 years ago

In order to prepare markers so that when they appear they are tooltip compliant, I tried implementing the following snippet of code like so:

        this._pruneCluster.PrepareLeafletMarker = function (leafletMarker, data) {
            leafletMarker.bindTooltip("my tooltip text").openTooltip();
        }

However I get the following error:

leaflet.draw-src.js:2200 Uncaught TypeError: Cannot read property '_panes' of undefined and I believe it has something to do with the fact that I'm adding pruneCluster to layer instead of adding the marker to layer. Any thoughts or workarounds?

fungiboletus commented 7 years ago

Hei,

It's maybe because PrepareLeafletMarker is sometimes executed before the marker is added to the map. So bindTooltip or openTooltip cannot be executed.

Could you try to open the tooltip in this portion of the source code : https://github.com/SINTEF-9012/PruneCluster/blob/57d6b066317cf878e779d0957d98c6e8c213ecdf/LeafletAdapter.ts#L580-L581 ? m should be a Leaflet marker.

axelerate commented 7 years ago

Upgraded to Leaflet 1.0.0 stable release, and the problem is gone.