I am using the Leaflet.TextPath plugin for labeling polylines. It works fine into my Leaflet map, but I want to set the zoom level (scale-based visibility) from which labels would be displayed on the map.
How can I do that?
labelingleafletzoom
I am using the Leaflet.TextPath plugin for labeling polylines. It works fine into my Leaflet map, but I want to set the zoom level (scale-based visibility) from which labels would be displayed on the map.
How can I do that?
Best Answer
In Leaflet, you don't specify zoom levels for visibility and let Leaflet handle visibility (except for
L.TileLayer
s), but rather the other way around: depending on the zoom level, you make something (in)visible by yourself.The usual way to do this is reacting to
zoomend
events, e.g.:If you're using Leaflet.TextPath then you probably don't want to
remove
andaddTo
anyL.Layer
s, but instead do something like