Take care not to change layer visibility when changing layer draw order (allOverlays only). r=ahocevar (closes #2004)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9216 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-04-06 21:15:39 +00:00
parent ebb7a08325
commit 85974d11a0
2 changed files with 17 additions and 3 deletions

View File

@@ -1098,7 +1098,7 @@ OpenLayers.Map = OpenLayers.Class({
if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
// make the old base layer invisible
if (this.baseLayer != null) {
if (this.baseLayer != null && !this.allOverlays) {
this.baseLayer.setVisibility(false);
}
@@ -1109,7 +1109,9 @@ OpenLayers.Map = OpenLayers.Class({
// changing. This is used by tiles to check if they should
// draw themselves.
this.viewRequestID++;
this.baseLayer.visibility = true;
if(!this.allOverlays) {
this.baseLayer.visibility = true;
}
//redraw all layers
var center = this.getCenter();

View File

@@ -1208,7 +1208,7 @@
function test_allOverlays(t) {
t.plan(9);
t.plan(14);
var map = new OpenLayers.Map({
div: "map", allOverlays: true
@@ -1264,8 +1264,20 @@
t.eq(map.baseLayer.name, "b", "raising the base layer sets a new base layer");
map.raiseLayer(d, -1);
// d, b, c, a
t.eq(map.baseLayer.name, "d", "lowering a layer to lowest index sets as base");
// all this switching of base layer didn't muck with layer visibility
t.eq(a.visibility, true, "a is visible");
t.eq(b.visibility, true, "b is visible");
t.eq(c.visibility, true, "c is visible");
t.eq(d.visibility, true, "d is visible");
// test that map can have an invisible base layer
b.setVisibility(false);
map.setLayerIndex(b, 0);
t.eq(b.visibility, false, "changing layer order doesn't change visibility");
map.destroy();
}