Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
601 stars 193 forks source link

How to disable displaying a layer #243

Closed Detinator10 closed 4 years ago

Detinator10 commented 4 years ago

I have a protobuf tile server set up that serves vector tiles with 16 different style layers in it. At any time, I only want to display the layers I enabled in my website app. How can I disable a layer from displaying completely? Right now, I am just turning the opacity and fill opacity to 0 and reloading the layer. I am wondering if there is a better way to disable the layer. Is there an options to prevent it from rendering completely or is leaflet smart enough to not render it anyways if it is completely transparent. I saw that there was an issue opened here that seems to be similar but I'm not sure what it means by setting L.path to an empty array: https://github.com/Leaflet/Leaflet.VectorGrid/issues/60

IvanSanchez commented 4 years ago

Duplicate of #60. If #60 says "See the road: [] bit in the example in the README.", then do read the source code for the examples, FFS.