FixedZoomLevels.js doesn't properly set the resolutions array. Special thanks to Sebastien Roch for the bug report and to Tim Schaub for the code review and extra comments. (closes #1124)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5318 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2007-12-01 14:04:18 +00:00
parent 76fa0da3b7
commit f6091b2ecf
2 changed files with 15 additions and 3 deletions

View File

@@ -105,7 +105,7 @@ OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class({
if (this.RESOLUTIONS != null) {
var resolutionsIndex = 0;
this.resolutions = [];
for(var i= this.minZoomLevel; i < this.numZoomLevels; i++) {
for(var i= this.minZoomLevel; i <= this.maxZoomLevel; i++) {
this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];
}
}

View File

@@ -5,7 +5,7 @@
var layer;
function test_01_Layer_FixedZoomLevels (t) {
t.plan( 36 );
t.plan( 39 );
var layer = { 'MIN_ZOOM_LEVEL': 5,
'MAX_ZOOM_LEVEL': 10 };
@@ -67,8 +67,20 @@
layer = p_createLayer(layer, {maxZoomLevel: 8, numZoomLevels: 6});
p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, 10, "min,max(layer.options) wins over (map)");
// resolutions array
var resolutions = Array(20);
for (var i = 0; i < 20; i++) {
resolutions[i] = Math.random();
}
OpenLayers.Util.extend(layer, {RESOLUTIONS:resolutions});
var minZoomLevel = 6;
var numZoomLevels = 2;
layer = p_createLayer(layer, {}, {minZoomLevel: minZoomLevel, numZoomLevels: numZoomLevels});
t.eq( layer.resolutions.length, numZoomLevels, "length of resolutions array ok");
for (var i = 0; i < numZoomLevels; i++) {
t.eq( layer.resolutions[i], resolutions[i + minZoomLevel], "resolutions array at index " + i + " ok");
}
}
function p_createLayer(layer, mapOptions, layerOptions) {