Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update opacity of WMS layer in leaflet?

How do I adjust opacity in leaflet without calling "removeLayer"? I have already used "map.addLayer(myLayer)" to my map. I see that there is a setParams() method, but it appears to have no effect when I call "myLayer.setParams({opacity:0.1})" and there is no refresh button for the WMS. Is this even possible in Leaflet? If so, how? Is there even someway to call something along the lines of "map.getLayers()" or something to be able to retrieve already added layers to the map?

like image 449
Setsuna Avatar asked Apr 10 '13 04:04

Setsuna


1 Answers

Use setOpacity like layer.setOpacity(0.5)

API Docs - http://leafletjs.com/reference.html#tilelayer-opacity (scroll down a bit)

like image 107
snkashis Avatar answered Oct 28 '22 20:10

snkashis