Give the WMS Layer an option to turn off the 'magic' of changing format and
baseLayer state, since that magic can sometimes be problematic. Patch by part, cleaned up a bit by me, r=me, (Closes #1980) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9029 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -55,6 +55,15 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
*/
|
*/
|
||||||
encodeBBOX: false,
|
encodeBBOX: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: noMagic
|
||||||
|
* {Boolean} If true, the image format will not be automagicaly switched
|
||||||
|
* from image/jpeg to image/png or image/gif when using
|
||||||
|
* TRANSPARENT=TRUE. Also isBaseLayer will not changed by the
|
||||||
|
* constructor. Default false.
|
||||||
|
*/
|
||||||
|
noMagic: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Layer.WMS
|
* Constructor: OpenLayers.Layer.WMS
|
||||||
* Create a new WMS layer object
|
* Create a new WMS layer object
|
||||||
@@ -87,7 +96,7 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
|
|
||||||
|
|
||||||
//layer is transparent
|
//layer is transparent
|
||||||
if (this.params.TRANSPARENT &&
|
if (!this.noMagic && this.params.TRANSPARENT &&
|
||||||
this.params.TRANSPARENT.toString().toLowerCase() == "true") {
|
this.params.TRANSPARENT.toString().toLowerCase() == "true") {
|
||||||
|
|
||||||
// unless explicitly set in options, make layer an overlay
|
// unless explicitly set in options, make layer an overlay
|
||||||
|
|||||||
+12
-1
@@ -15,7 +15,7 @@
|
|||||||
format: 'image/jpeg'};
|
format: 'image/jpeg'};
|
||||||
|
|
||||||
function test_Layer_WMS_constructor (t) {
|
function test_Layer_WMS_constructor (t) {
|
||||||
t.plan( 13 );
|
t.plan( 15 );
|
||||||
|
|
||||||
var trans_format = "image/png";
|
var trans_format = "image/png";
|
||||||
if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; }
|
if (OpenLayers.Util.alphaHack()) { trans_format = "image/gif"; }
|
||||||
@@ -52,6 +52,17 @@
|
|||||||
params.TRANSPARENT = false;
|
params.TRANSPARENT = false;
|
||||||
var layer6 = new OpenLayers.Layer.WMS(name, url, params);
|
var layer6 = new OpenLayers.Layer.WMS(name, url, params);
|
||||||
t.eq(layer6.isBaseLayer, true, "transparency == false, wms is baselayer");
|
t.eq(layer6.isBaseLayer, true, "transparency == false, wms is baselayer");
|
||||||
|
|
||||||
|
params.TRANSPARENT = true;
|
||||||
|
var layer7 = new OpenLayers.Layer.WMS(name, url, params, {noMagic: true});
|
||||||
|
t.eq(layer7.params.FORMAT, "image/jpeg", "When using noMagic true image/jpeg will not be automagically switched to image/png or image/gif if transparent");
|
||||||
|
|
||||||
|
params.TRANSPARENT = true;
|
||||||
|
var layer8 = new OpenLayers.Layer.WMS(name, url, params, {noMagic: true});
|
||||||
|
t.eq(layer8.isBaseLayer, true, "When using noMagic then transparent means the wms layer is not automagically changed to not being a baselayer");
|
||||||
|
|
||||||
|
params.TRANSPARENT = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_WMS_addtile (t) {
|
function test_Layer_WMS_addtile (t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user