SINTEF-9012 / PruneCluster

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

Bug on tooltip with pruneCluster #131

Open wahisoufiane opened 8 years ago

wahisoufiane commented 8 years ago

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

fungiboletus commented 8 years ago

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.

wahisoufiane commented 8 years ago

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

On Tue, Aug 30, 2016 at 6:40 PM, Antoine Pultier notifications@github.com 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

fungiboletus commented 8 years ago

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

wahisoufiane commented 8 years ago

Great! Thank you anyway

On Tue, Aug 30, 2016 at 6:46 PM, Antoine Pultier notifications@github.com 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

simison commented 8 years ago

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

wahisoufiane commented 8 years ago

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 notifications@github.com 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

simison commented 8 years ago

@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.

fungiboletus commented 8 years ago

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.

wahisoufiane commented 8 years ago

@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 notifications@github.com 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 commented 8 years ago

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.

axelerate commented 7 years ago

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?

wahisoufiane commented 7 years ago

any news on this bug?

cordovapolymer commented 7 years ago

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

ghost commented 7 years ago

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.