diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 85834f51b0..d79e559c9b 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1926,6 +1926,11 @@ OpenLayers.Map = OpenLayers.Class({ var resolution = null; if (this.baseLayer != null) { resolution = this.baseLayer.getResolution(); + } else if(this.allOverlays === true && this.layers.length > 0) { + // while adding the 1st layer to the map in allOverlays mode, + // this.baseLayer is not set yet when we need the resolution + // for calculateInRange. + resolution = this.layers[0].getResolution(); } return resolution; }, diff --git a/tests/Map.html b/tests/Map.html index 087833b67d..7cfc70d108 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -1315,7 +1315,7 @@ function test_allOverlays(t) { - t.plan(17); + t.plan(18); var map = new OpenLayers.Map({ div: "map", allOverlays: true @@ -1406,6 +1406,7 @@ var count = 0; var layer = new OpenLayers.Layer(null, { visibility: true, + maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90), setVisibility: function() { ++count; OpenLayers.Layer.prototype.setVisibility.apply(this, arguments); @@ -1415,6 +1416,7 @@ map.zoomToMaxExtent(); t.eq(count, 1, "setVisibility called when visibility is true in layer config"); + t.eq(layer.div.style.display, "", "layer is visible."); map.destroy();