give map::getResolution a fallback from baseLayer to the 1st layer if in allOverlays mode. r=tschaub (closes #2479)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10043 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-02-10 19:05:58 +00:00
parent e5e4d49d33
commit 2e47542fbe
2 changed files with 8 additions and 1 deletions

View File

@@ -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;
},

View File

@@ -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();