diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index cdb1bc01de..bf19b13077 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1122,7 +1122,7 @@ OpenLayers.Map = OpenLayers.Class({ // changing. This is used by tiles to check if they should // draw themselves. this.viewRequestID++; - if(!this.allOverlays) { + if(!this.allOverlays || this.baseLayer.visibility) { this.baseLayer.setVisibility(true); } diff --git a/tests/Map.html b/tests/Map.html index 702ed21d78..487deed50e 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -1225,7 +1225,7 @@ function test_allOverlays(t) { - t.plan(16); + t.plan(17); var map = new OpenLayers.Map({ div: "map", allOverlays: true @@ -1309,6 +1309,25 @@ map.destroy(); + // make sure setVisibility is called when adding a single layer to the map + map = new OpenLayers.Map({ + div: "map", allOverlays: true + }); + var count = 0; + var layer = new OpenLayers.Layer(null, { + visibility: true, + setVisibility: function() { + ++count; + OpenLayers.Layer.prototype.setVisibility.apply(this, arguments); + } + }); + map.addLayer(layer); + map.zoomToMaxExtent(); + + t.eq(count, 1, "setVisibility called when visibility is true in layer config"); + + map.destroy(); + } function test_panTo(t) {