PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

Bug on tooltip with pruneCluster

Open wahisoufiane opened this issue 9 years ago • 14 comments
trafficstars

Hi,

I'm using Leaflet 1.0.0-rc2 and the plugin PruneCluster. When I bindTooltip to markers and add them to prunecluster, the tooltips didn't show up, but when I Unzoom or zoom, the tooltip works.

Here is a demo : http://playground-leaflet.rhcloud.com/dat/edit?html,js,console,output

wahisoufiane avatar Aug 30 '16 17:08 wahisoufiane

Hi,

Thanks for the demo. I see in Leaflet's changelog that tooltips have just been introduced this summer.

I don't have time to add support for them now, but maybe later this year.

fungiboletus avatar Aug 30 '16 17:08 fungiboletus

Maybe I could help with it if you give me a hint!

On Tue, Aug 30, 2016 at 6:40 PM, Antoine Pultier [email protected] wrote:

Hi,

Thanks for the demo. I see in Leaflet's changelog https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md that tooltips have just been introduced this summer.

I don't have time to add support for them now, but maybe later this year.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SINTEF-9012/PruneCluster/issues/131#issuecomment-243519374, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_WRI5qSIX1vMMvjfVjdwk_muJbQPOQks5qlGr3gaJpZM4JwwtK .

Soufiane Wahi

Ingénieur Développement

Tel : +212 626 416 382

wahisoufiane avatar Aug 30 '16 17:08 wahisoufiane

Yes, I can look at the problem soon but I don't promise anything.

fungiboletus avatar Aug 30 '16 17:08 fungiboletus

Great! Thank you anyway

On Tue, Aug 30, 2016 at 6:46 PM, Antoine Pultier [email protected] wrote:

Yes, I can look at the problem soon but I don't promise anything.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SINTEF-9012/PruneCluster/issues/131#issuecomment-243521196, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_WRCMIwaee6gepBMDEsiEisGxYOkIhks5qlGxjgaJpZM4JwwtK .

Soufiane Wahi

Ingénieur Développement

Tel : +212 626 416 382

wahisoufiane avatar Aug 30 '16 17:08 wahisoufiane

Maybe something like this here? https://github.com/SINTEF-9012/PruneCluster/blob/master/LeafletAdapter.ts#L213-L220

simison avatar Aug 30 '16 18:08 simison

I think it doesn't have to do with the popup, but the tooltip. The problem is that the marker has to be added to the map before binding the tooltip, and what I did is that I bind the tooltip to the marker in prepareleafletmarker, and it doesn't been add to the map yet.

Where do you think I have to bind tooltip instead of prepareleafletmarker?

On Tue, Aug 30, 2016 at 7:53 PM, Mikael Korpela [email protected] wrote:

Maybe something here? https://github.com/SINTEF- 9012/PruneCluster/blob/master/LeafletAdapter.ts#L213-L220

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SINTEF-9012/PruneCluster/issues/131#issuecomment-243541989, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_WRAEdmOduzXv-1vGJW26LOWsP1foVks5qlHwngaJpZM4JwwtK .

Soufiane Wahi

Ingénieur Développement

Tel : +212 626 416 382

wahisoufiane avatar Aug 31 '16 15:08 wahisoufiane

@wahisoufiane I meant that perhaps something similar should be added to PruneCluster for Tooltip as it's done for for Popup. But I really just had a quick look, so just a guess.

simison avatar Aug 31 '16 15:08 simison

If the label must be attached after a marker is added to the map, it seems more like a bug in Leaflet.

PrepareLeafletMarker is the correct place to do this. The marker is sometimes on a map because PruneCluster recycle the markers. If it isn't, a quick&dirty workaround would be setting the label inside a setImmediate or setTimeout inside PrepareLeafletMarker, or something more intelligent but I would say this needs to be fixed in Leaflet instead.

fungiboletus avatar Aug 31 '16 15:08 fungiboletus

@MikaelKorpela Ok I didn't get you on the first place. Now I see what you meant

@AntoinePultier here is the Issue for the add marker before the tooltip : https://github.com/Leaflet/Leaflet/issues/4778 and also here is what the admin told me on the issue of this bug : https://github.com/Leaflet/Leaflet/issues/4863

On Wed, Aug 31, 2016 at 4:57 PM, Antoine Pultier [email protected] wrote:

If the label must be attached after a marker is added to the map, it seems more like a bug in Leaflet.

PrepareLeafletMarker is the correct place to do this. The marker is sometimes on a map because PruneCluster recycle the markers. If it isn't, a quick&dirty workaround would be setting the label inside a setImmediate or setTimeout inside PrepareLeafletMarker, or something more intelligent but I would say this needs to be fixed in Leaflet instead.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SINTEF-9012/PruneCluster/issues/131#issuecomment-243811108, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_WROktpCOn7HNLY6CU7XqAfRBYBVEDks5qlaRcgaJpZM4JwwtK .

Soufiane Wahi

Ingénieur Développement

Tel : +212 626 416 382

wahisoufiane avatar Aug 31 '16 16:08 wahisoufiane

Just for the test I add this line m.addTo(map) juste before this.PrepareLeafletMarker(m,marker.data,marker.category) in BuildLeafletMarker function, and in the processView, I added this line if(!map.hasLayer(creationMarker)) as a condition before creationMarker.addTo(map) and it works well.

Now we just have to find the right way to do that.

wahisoufiane avatar Aug 31 '16 16:08 wahisoufiane

Hey there. I tried doing the suggestion brought on by @simison, 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?

axelerate avatar Sep 23 '16 21:09 axelerate

any news on this bug?

wahisoufiane avatar Nov 12 '16 09:11 wahisoufiane

@yellowiscool @simison @FalloutPL @mordka @vitalik74 @rwwagner90 @brunolellis @maxvonhippel @Cadrach @undr @uniphil @valerio-bozzolan @rolanddu @adimasci @maxhoffmann BUMP!

cordovapolymer avatar Mar 10 '17 23:03 cordovapolymer

This doesn't seem to be a tooltip specific issue, but an issue related with PrepareLeafletMarker not being fired on initial load.

Custom icons, click effects, tooltips or anything that resides within PrepareLeafletMarker isn't executed before i either zoom in or out, it seems like PruneCluster was made thinking that all markers initially load within a cluster by default and zoom is therefor required to reveal them.

ghost avatar Aug 03 '17 08:08 ghost