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:
@@ -105,7 +105,7 @@ OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class({
|
|||||||
if (this.RESOLUTIONS != null) {
|
if (this.RESOLUTIONS != null) {
|
||||||
var resolutionsIndex = 0;
|
var resolutionsIndex = 0;
|
||||||
this.resolutions = [];
|
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];
|
this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
function test_01_Layer_FixedZoomLevels (t) {
|
function test_01_Layer_FixedZoomLevels (t) {
|
||||||
t.plan( 36 );
|
t.plan( 39 );
|
||||||
|
|
||||||
var layer = { 'MIN_ZOOM_LEVEL': 5,
|
var layer = { 'MIN_ZOOM_LEVEL': 5,
|
||||||
'MAX_ZOOM_LEVEL': 10 };
|
'MAX_ZOOM_LEVEL': 10 };
|
||||||
@@ -67,8 +67,20 @@
|
|||||||
layer = p_createLayer(layer, {maxZoomLevel: 8, numZoomLevels: 6});
|
layer = p_createLayer(layer, {maxZoomLevel: 8, numZoomLevels: 6});
|
||||||
p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, 10, "min,max(layer.options) wins over (map)");
|
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) {
|
function p_createLayer(layer, mapOptions, layerOptions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user