From fe720b259e05a0044266148dfc8455efe7c58199 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 25 Jul 2011 11:42:43 +0000 Subject: [PATCH] Set opacity on layer div, not on tiles and markers. r=fredj (closes #3431) git-svn-id: http://svn.openlayers.org/trunk/openlayers@12185 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer.js | 12 +++++---- lib/OpenLayers/Layer/Markers.js | 16 ------------ lib/OpenLayers/Layer/WFS.js | 16 ------------ tests/Layer.html | 12 +++++++-- tests/Layer/ArcGIS93Rest.html | 25 ------------------ tests/Layer/MapServer.html | 46 --------------------------------- tests/Layer/Markers.html | 27 ------------------- tests/Layer/WFS.html | 16 ------------ tests/Layer/WMS.html | 25 ------------------ 9 files changed, 17 insertions(+), 178 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 4a2cc4b8eb..763e3800a0 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -349,6 +349,11 @@ OpenLayers.Layer = OpenLayers.Class({ this.div.style.width = "100%"; this.div.style.height = "100%"; this.div.dir = "ltr"; + if (this.opacity != null) { + OpenLayers.Util.modifyDOMElement( + this.div, null, null, null, null, null, null, this.opacity + ); + } this.events = new OpenLayers.Events(this, this.div, this.EVENT_TYPES); @@ -1269,11 +1274,8 @@ OpenLayers.Layer = OpenLayers.Class({ setOpacity: function(opacity) { if (opacity != this.opacity) { this.opacity = opacity; - for(var i=0, len=this.div.childNodes.length; i diff --git a/tests/Layer/WFS.html b/tests/Layer/WFS.html index 42b566acfe..b9f85182d2 100644 --- a/tests/Layer/WFS.html +++ b/tests/Layer/WFS.html @@ -25,22 +25,6 @@ } - function test_Layer_WFS_setOpacity(t) { - t.plan(3); - - var layer = new OpenLayers.Layer.WFS(name, "url", {}); - layer.setOpacity(.5); - t.eq(layer.opacity, 0.5, "vector setOpacity didn't fail"); - var layer = new OpenLayers.Layer.WFS(name, "url", {}, {'featureClass': OpenLayers.Feature.WFS}); - var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0)); - marker.setOpacity = function() { - t.ok(true, "Marker setOpacity was called"); - } - layer.addMarker(marker); - layer.setOpacity(.6); - t.eq(layer.opacity, 0.6, "setOpacity didn't fail on markers"); - } - function test_Layer_WFS_destroy(t) { t.plan(13); diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index 05b2adb64c..557395df30 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -281,31 +281,6 @@ } - function test_Layer_WMS_setOpacity (t) { - t.plan( 5 ); - - var map = new OpenLayers.Map('map'); - map.projection = "xx"; - tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; - tParams = { layers: 'basic', - format: 'image/png'}; - tOptions = { 'opacity': '0.5' }; - var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions); - map.addLayer(tLayer); - map.zoomToMaxExtent(); - t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); - t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); - tLayer.setOpacity("0.6"); - t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); - t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); - var pixel = new OpenLayers.Pixel(5,6); - var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); - tile.draw(); - t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); - - map.destroy(); - } - function test_Layer_WMS_Reproject (t) { var validkey = (window.location.protocol == "file:") || (window.location.host == "localhost") ||