Changeset 1433
- Timestamp:
- 09/11/06 10:30:25 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Tile/Image.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (1 diff)
- trunk/openlayers/tests/test_Layer_WMS.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer.js
r1424 r1433 436 436 ); 437 437 }, 438 439 /** 440 * Sets the opacity for the entire layer (all images) 441 * @param {Float} opacity 442 */ 443 setOpacity: function(opacity) { 444 this.opacity = opacity; 445 for(var i=0; i<this.div.childNodes.length; ++i) { 446 var element = this.div.childNodes[i]; 447 OpenLayers.Util.setOpacity(element, opacity); 448 } 449 }, 438 450 439 451 /** @final @type String */ trunk/openlayers/lib/OpenLayers/Tile/Image.js
r1424 r1433 103 103 } 104 104 this.layer.div.appendChild(this.imgDiv); 105 if(this.layer.opacity != null) { 106 OpenLayers.Util.setOpacity(this.imgDiv, this.layer.opacity); 107 } 105 108 }, 106 109 trunk/openlayers/lib/OpenLayers/Util.js
r1424 r1433 126 126 }; 127 127 128 /** 129 * Set the opacity of a DOM Element 130 * Note that for this function to work in IE, elements must "have layout" 131 * according to: 132 * http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/haslayout.asp 133 * 134 * @param {DOMElement} element Set the opacity on this DOM element 135 * @param {Float} opacity Opacity value (0.0 - 1.0) 136 */ 137 OpenLayers.Util.setOpacity = function(element, opacity) { 138 element.style.opacity = opacity; 139 element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')'; 140 } 128 141 129 142 OpenLayers.Util.onImageLoad = function() { trunk/openlayers/tests/test_Layer_WMS.html
r1424 r1433 150 150 151 151 } 152 153 function test_08_Layer_WMS_setOpacity (t) { 154 t.plan( 5 ); 155 156 var map = new OpenLayers.Map('map'); 157 map.projection = "xx"; 158 tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; 159 tParams = { layers: 'basic', 160 format: 'image/png'}; 161 tOptions = { 'opacity': '0.5' }; 162 var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions); 163 map.addLayer(tLayer); 164 map.zoomToMaxExtent(); 165 t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); 166 t.eq(tLayer.div.firstChild.style.opacity, "0.5", "Opacity on tile is correct"); 167 tLayer.setOpacity("0.6"); 168 t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); 169 t.eq(tLayer.div.firstChild.style.opacity, "0.6", "Opacity on tile is changed correctly"); 170 var pixel = new OpenLayers.Pixel(5,6); 171 var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); 172 tile.draw(); 173 t.eq(tile.imgDiv.style.opacity, "0.6", "Tile opacity is set correctly"); 174 175 } 176 152 177 153 178 function test_99_Layer_WMS_destroy (t) {
