id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	state
235	patch that allows layer opacity to be set	tschaub		"The following patch allows you to create a partially transparent layer.  You do this by setting an opacity option when constructing the layer.  For example:

{{{
            var shade = new OpenLayers.Layer.WMS(""Shaded Relief"",
                ""http://ims.cr.usgs.gov:80/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3"", 
                {layers: ""HR-NED.IMAGE"", reaspect: ""false"", transparent: 'true'},
                {isBaseLayer: false, opacity: 0.30});

}}}

''Note that if you want the layer to act as an overlay, you have to add the transparent: 'true' parameter to your WMS layer - even though the server has nothing to do with the layer transparency in this case.  The key part here is the opacity: 0.30 option.''

An example of this partially transparent shaded relief in action can be seen here:
[http://dev.geocartic.com/openlayers/examples/layer-opacity.html]


The simple patch to follow creates a partially opaque (or transparent) layer based on the opacity option.

Also, if you want to change the opacity of a layer after it has been added to the map, you could add the following method to the Layer class in Layer.js:


{{{
    /**
     * Sets the opacity for the entire layer (all images)
     * @param {Float} opacity
     */
    setOpacity: function(opacity) {
        for(var i=0; i<this.div.childNodes.length; ++i) {
            var element = this.div.childNodes[i];
            OpenLayers.Util.setOpacity(element, opacity);
        }
    },

}}}

"	feature	closed	minor	2.1 Release	general		fixed			
