Leaflet: Hide/show tooltip according to zoom level

Created on 21 Oct 2016  路  8Comments  路  Source: Leaflet/Leaflet

When permanent is true, it would be useful to hide tooltips under certain zoom levels. Is it visible to provide such feature as build-in in leaflet?

Most helpful comment

@nouphaltklm This should be the code: https://stackoverflow.com/a/42373256/

All 8 comments

+1

There's a lot of functions you might want to trigger at different zoom levels, and I don't think we should add all those to Leaflet's core. It's actually not that hard to do this already, see this example:
http://playground-leaflet.rhcloud.com/sere/edit?html,output

Can probably be cleaned up a bit, but I hope the general idea is clear.

@perliedman Very clear; thanks for the demo!

Hello Guys,

I'm new to this framework, is there any way to hide/close permanent tooltip at the default zoom level?

The mentioned the example only works there is a zoom level change.

Regards
JJ

@knightg if you check the example, it uses the map's closeTooltip method to hide a permanent tooltip, and then uses addLayer to show it again.

@perliedman its a broken link http://playground-leaflet.rhcloud.com/sere/edit?html,output

@nouphaltklm yeah, sorry, it appears the playground has gone down and apparently the code is lost with it.

@nouphaltklm This should be the code: https://stackoverflow.com/a/42373256/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

walterfn2 picture walterfn2  路  4Comments

edmsgists picture edmsgists  路  3Comments

prbaron picture prbaron  路  3Comments

ssured picture ssured  路  3Comments

arminghm picture arminghm  路  3Comments