reverting r12228 and r12185 (closes #3431)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12231 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -347,17 +347,9 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||||
|
|
||||||
this.div = OpenLayers.Util.createDiv(this.id);
|
this.div = OpenLayers.Util.createDiv(this.id);
|
||||||
var style = this.div.style;
|
this.div.style.width = "100%";
|
||||||
style.width = "100%";
|
this.div.style.height = "100%";
|
||||||
style.height = "100%";
|
|
||||||
style.overflow = "";
|
|
||||||
this.div.className = "olLayerDiv";
|
|
||||||
this.div.dir = "ltr";
|
this.div.dir = "ltr";
|
||||||
if (this.opacity != null && this.opacity < 1) {
|
|
||||||
OpenLayers.Util.modifyDOMElement(
|
|
||||||
this.div, null, null, null, null, null, null, this.opacity
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.events = new OpenLayers.Events(this, this.div,
|
this.events = new OpenLayers.Events(this, this.div,
|
||||||
this.EVENT_TYPES);
|
this.EVENT_TYPES);
|
||||||
@@ -370,19 +362,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
if (this.wrapDateLine) {
|
if (this.wrapDateLine) {
|
||||||
this.displayOutsideMaxExtent = true;
|
this.displayOutsideMaxExtent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO remove the if block below when we drop support for IE8.
|
|
||||||
if (parseInt(navigator.appVersion.split("MSIE")[1], 10) == 8) {
|
|
||||||
// Workaround for opacity handling in IE8 - also see
|
|
||||||
// .ie8-opacity-hack selectors in theme/default/style.css
|
|
||||||
this.events.register("loadend", this, function() {
|
|
||||||
var opacity = this.opacity;
|
|
||||||
if (opacity != null && opacity >= 0 && opacity < 1) {
|
|
||||||
OpenLayers.Element.addClass(this.div, "ie8-opacity-hack");
|
|
||||||
this.div.style.filter = "alpha(opacity=" + (opacity * 100) + ")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1291,8 +1270,11 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
setOpacity: function(opacity) {
|
setOpacity: function(opacity) {
|
||||||
if (opacity != this.opacity) {
|
if (opacity != this.opacity) {
|
||||||
this.opacity = opacity;
|
this.opacity = opacity;
|
||||||
OpenLayers.Util.modifyDOMElement(this.div, null, null, null,
|
for(var i=0, len=this.div.childNodes.length; i<len; ++i) {
|
||||||
null, null, null, opacity);
|
var element = this.div.childNodes[i].firstChild;
|
||||||
|
OpenLayers.Util.modifyDOMElement(element, null, null, null,
|
||||||
|
null, null, null, opacity);
|
||||||
|
}
|
||||||
if (this.map != null) {
|
if (this.map != null) {
|
||||||
this.map.events.triggerEvent("changelayer", {
|
this.map.events.triggerEvent("changelayer", {
|
||||||
layer: this,
|
layer: this,
|
||||||
|
|||||||
@@ -60,6 +60,22 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: setOpacity
|
||||||
|
* Sets the opacity for all the markers.
|
||||||
|
*
|
||||||
|
* Parameter:
|
||||||
|
* opacity - {Float}
|
||||||
|
*/
|
||||||
|
setOpacity: function(opacity) {
|
||||||
|
if (opacity != this.opacity) {
|
||||||
|
this.opacity = opacity;
|
||||||
|
for (var i=0, len=this.markers.length; i<len; i++) {
|
||||||
|
this.markers[i].setOpacity(this.opacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: moveTo
|
* Method: moveTo
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -590,5 +590,21 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
|||||||
return extent;
|
return extent;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: setOpacity
|
||||||
|
* Call the setOpacity method of the appropriate parent class to set the
|
||||||
|
* opacity.
|
||||||
|
*
|
||||||
|
* Parameter:
|
||||||
|
* opacity - {Float}
|
||||||
|
*/
|
||||||
|
setOpacity: function (opacity) {
|
||||||
|
if (this.vectorMode) {
|
||||||
|
OpenLayers.Layer.Vector.prototype.setOpacity.apply(this, [opacity]);
|
||||||
|
} else {
|
||||||
|
OpenLayers.Layer.Markers.prototype.setOpacity.apply(this, [opacity]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Layer.WFS"
|
CLASS_NAME: "OpenLayers.Layer.WFS"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -971,6 +971,8 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
layer.div.className = "olLayerDiv";
|
||||||
|
layer.div.style.overflow = "";
|
||||||
this.setLayerZIndex(layer, this.layers.length);
|
this.setLayerZIndex(layer, this.layers.length);
|
||||||
|
|
||||||
if (layer.isFixed) {
|
if (layer.isFixed) {
|
||||||
|
|||||||
@@ -786,15 +786,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_setOpacity(t) {
|
function test_setOpacity(t) {
|
||||||
t.plan(8);
|
t.plan(5);
|
||||||
|
|
||||||
var map, layer, log;
|
var map, layer, log;
|
||||||
|
|
||||||
map = new OpenLayers.Map("map");
|
map = new OpenLayers.Map("map");
|
||||||
layer = new OpenLayers.Layer("", {opacity: 0.56});
|
layer = new OpenLayers.Layer("");
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
|
|
||||||
t.eq(layer.div.style.opacity, "0.56", "initial opacity correctly applied as layer.div style");
|
|
||||||
log = [];
|
log = [];
|
||||||
map.events.register('changelayer', t, function(event) {
|
map.events.register('changelayer', t, function(event) {
|
||||||
log.push({layer: event.layer, property: event.property});
|
log.push({layer: event.layer, property: event.property});
|
||||||
@@ -802,7 +801,6 @@
|
|||||||
layer.setOpacity(0.42);
|
layer.setOpacity(0.42);
|
||||||
t.eq(layer.opacity, 0.42,
|
t.eq(layer.opacity, 0.42,
|
||||||
"setOpacity() set layer.opacity to correct value");
|
"setOpacity() set layer.opacity to correct value");
|
||||||
t.eq(layer.div.style.opacity, "0.42", "opacity correctly applied as layer.div style");
|
|
||||||
t.eq(log.length, 1,
|
t.eq(log.length, 1,
|
||||||
"setOpacity() triggers changelayer once");
|
"setOpacity() triggers changelayer once");
|
||||||
t.ok(log[0].layer == layer,
|
t.ok(log[0].layer == layer,
|
||||||
@@ -815,12 +813,6 @@
|
|||||||
layer.setOpacity(0.42);
|
layer.setOpacity(0.42);
|
||||||
t.eq(log.length, 0,
|
t.eq(log.length, 0,
|
||||||
"setOpacity() does not trigger changelayer if the opacity value is the same");
|
"setOpacity() does not trigger changelayer if the opacity value is the same");
|
||||||
|
|
||||||
// 0 as initial opacity
|
|
||||||
layer.destroy();
|
|
||||||
layer = new OpenLayers.Layer("", {opacity: 0});
|
|
||||||
map.addLayer(layer);
|
|
||||||
t.eq(layer.div.style.opacity, "0", "initial opacity correctly applied as layer.div style");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,31 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_Layer_AGS93_setOpacity (t) {
|
||||||
|
var params = {layers: "show:0,2"};
|
||||||
|
t.plan( 5 );
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
map.projection = "xx";
|
||||||
|
tParams = { layers: 'show:0,2',
|
||||||
|
format: 'png'};
|
||||||
|
tOptions = { 'opacity': '0.5' };
|
||||||
|
var tLayer = new OpenLayers.Layer.ArcGIS93Rest(name, url, 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_AGS93_noGutters (t) {
|
function test_Layer_AGS93_noGutters (t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
|
|||||||
@@ -196,6 +196,31 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_Layer_MapServer_setOpacity (t) {
|
||||||
|
t.plan( 5 );
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
map.projection = "xx";
|
||||||
|
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
|
||||||
|
tParams = { layers: 'basic',
|
||||||
|
format: 'image/png'};
|
||||||
|
tOptions = { 'opacity': '0.5' };
|
||||||
|
var tLayer = new OpenLayers.Layer.MapServer(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_MapServer_Reproject (t) {
|
function test_Layer_MapServer_Reproject (t) {
|
||||||
var validkey = (window.location.protocol == "file:") ||
|
var validkey = (window.location.protocol == "file:") ||
|
||||||
(window.location.host == "localhost") ||
|
(window.location.host == "localhost") ||
|
||||||
@@ -386,6 +411,27 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_Layer_MapServer_Untiled_setOpacity (t) {
|
||||||
|
t.plan( 4 );
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
map.projection = "xx";
|
||||||
|
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
|
||||||
|
tParams = { layers: 'basic',
|
||||||
|
format: 'image/png'};
|
||||||
|
tOptions = { 'opacity': '0.5' };
|
||||||
|
var tLayer = new OpenLayers.Layer.MapServer.Untiled(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");
|
||||||
|
map.destroy();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// DEPRECATED -- REMOVE IN 3.0
|
// DEPRECATED -- REMOVE IN 3.0
|
||||||
function test_Layer_Untiled_MapServer(t) {
|
function test_Layer_Untiled_MapServer(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|||||||
@@ -121,6 +121,33 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_setOpacity(t) {
|
||||||
|
t.plan(1);
|
||||||
|
|
||||||
|
layer = new OpenLayers.Layer.Markers('Test Layer');
|
||||||
|
|
||||||
|
var opacity = 0.1234;
|
||||||
|
|
||||||
|
for (var i = 0; i < 12; i++) {
|
||||||
|
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.setOpacity(opacity);
|
||||||
|
|
||||||
|
for (var i = 0; i < 4; i++) {
|
||||||
|
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
var itWorks = false;
|
||||||
|
for (var i = 0; i < layer.markers.length; i++) {
|
||||||
|
itWorks = parseFloat(layer.markers[i].icon.imageDiv.style.opacity) == opacity;
|
||||||
|
if (!itWorks) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.ok(itWorks, "setOpacity change markers opacity");
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -25,6 +25,22 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function test_Layer_WFS_destroy(t) {
|
||||||
t.plan(13);
|
t.plan(13);
|
||||||
|
|
||||||
|
|||||||
@@ -281,6 +281,31 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function test_Layer_WMS_Reproject (t) {
|
||||||
var validkey = (window.location.protocol == "file:") ||
|
var validkey = (window.location.protocol == "file:") ||
|
||||||
(window.location.host == "localhost") ||
|
(window.location.host == "localhost") ||
|
||||||
|
|||||||
@@ -14,15 +14,6 @@ div.olLayerDiv {
|
|||||||
-khtml-user-select: none;
|
-khtml-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO remove the two style definitions below when we drop support for IE8 */
|
|
||||||
div.olLayerDiv.ie8-opacity-hack {
|
|
||||||
width: 9999px !important;
|
|
||||||
height: 9999px !important;
|
|
||||||
}
|
|
||||||
div.olLayerDiv.ie8-opacity-hack div, .ie8-opacity-hack img.olTileImage {
|
|
||||||
filter: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.olLayerGoogleCopyright {
|
.olLayerGoogleCopyright {
|
||||||
left: 2px;
|
left: 2px;
|
||||||
bottom: 2px;
|
bottom: 2px;
|
||||||
|
|||||||
Reference in New Issue
Block a user