Change layer opacity in ol3

I have a vague recollection of seeing Open Layers 3 examples where the transparency of added layers can be changed. There are still such examples on the ol3 sample page, but they require webgl-renderer (which excludes vector layers). Is there a way to change the opacity of vector and / or raster layers using conventional canvas rendering?

+4
source share
2 answers

I don’t know if any of his vector examples are used, but all ol3 layers support the setOpacity method: http://openlayers.org/en/v3.8.2/apidoc/ol.layer.Vector.html#setOpacity p>

+5
source

Here's how you do it for the image layer. For other layers, the same function is used:

myimage = new ol.layer.Image({ source: new ol.source.ImageStatic({ url:some_url, crossOrigin: '', projection: 'EPSG:26916', imageExtent: some_extent }), opacity: 1.0 }); . . . myimage.setOpacity(0.6); 
+1
source

All Articles