Changing the layer opacity
When you are working with many layers—both raster and vector layers—you will probably find situations where a layer that is on top of another layer hides the one below it. This is more common when working with raster WMS layers without the transparent
property set to true
or tiled layers such as, OpenStreetMaps, Google, and Bing. The layer opacity is set to 50% in the following screenshot:
The OpenLayers.Layer
base class has an opacity
property, implemented by concrete subclasses, that allows us to modify the opacity of the layers. It is a float value that can range from 0.0
(completely transparent) to 1.0
(completely opaque).
How to do it...
The opacity of the layers can be changed. To change the opacity of the layer, perform the following steps:
Create an HTML file adding the required OpenLayers dependencies.
Note
We have intentionally omitted the HTML code required for the slider control. Here, we have focused on the code for OpenLayers. If interested in knowing...