I want to use opacity on one of my WMS layers in Leaflet. The documentation has an opacity option for L.tileLayer but not explicitly for L.tileLayer.wms, I only see a transparent option (not supported for the WMS I want to use, I'm using a cascading WMS and it defaults to gif I think, I have not found a way how I can cascade it as a PNG). Does this mean that you can't use opacity only on L.tileLayer and not for L.tileLayer.wms?
This does not do anything:
var gemini = L.tileLayer.wms('rootUrl', {
layers: 'myLayer',
format: 'image/png',
maxZoom: 21,
opacity: 0.5;
});
Best Answer
The
opacity
option ofL.TileLayer.WMS
works as expected. See a working example.If you check the documentation for Leaflet 1.0, you'll see that a
L.TileLayer.WMS
inherits options, methods and events fromL.TileLayer
andL.GridLayer
.