make sure the for loop for lods is not messed up by frameworks changing the Array.prototype, p=dzwarg, r=me (closes #3474)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12269 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -172,21 +172,23 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
|
|
||||||
this.lods = [];
|
this.lods = [];
|
||||||
for(var key in info.tileInfo.lods) {
|
for(var key in info.tileInfo.lods) {
|
||||||
var lod = info.tileInfo.lods[key];
|
if (info.tileInfo.lods.hasOwnProperty(key)) {
|
||||||
if (this.useScales) {
|
var lod = info.tileInfo.lods[key];
|
||||||
this.scales.push(lod.scale);
|
if (this.useScales) {
|
||||||
} else {
|
this.scales.push(lod.scale);
|
||||||
this.resolutions.push(lod.resolution);
|
} else {
|
||||||
|
this.resolutions.push(lod.resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
|
||||||
|
lod.startTileCol = start.x;
|
||||||
|
lod.startTileRow = start.y;
|
||||||
|
|
||||||
|
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
|
||||||
|
lod.endTileCol = end.x;
|
||||||
|
lod.endTileRow = end.y;
|
||||||
|
this.lods.push(lod);
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
|
|
||||||
lod.startTileCol = start.x;
|
|
||||||
lod.startTileRow = start.y;
|
|
||||||
|
|
||||||
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
|
|
||||||
lod.endTileCol = end.x;
|
|
||||||
lod.endTileRow = end.y;
|
|
||||||
this.lods.push(lod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);
|
this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);
|
||||||
|
|||||||
@@ -219,6 +219,32 @@
|
|||||||
t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
|
t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that functions don't end up in the lods of the layer. This messes up zooming when
|
||||||
|
* resolutions are very small/scales are very large/zoomed way in.
|
||||||
|
*/
|
||||||
|
function test_Layer_ARCGISCACHE_lods (t) {
|
||||||
|
t.plan( 2 );
|
||||||
|
var layerInfo = capabilitiesObject;
|
||||||
|
|
||||||
|
lods = layerInfo.tileInfo.lods.length;
|
||||||
|
|
||||||
|
// mess up the Array prototype
|
||||||
|
Array.prototype.foo = function() { };
|
||||||
|
|
||||||
|
t.ok( lods == layerInfo.tileInfo.lods.length, 'proper number of "Levels of Detail" before initialization' );
|
||||||
|
|
||||||
|
// initialize the layer using the JSON object from an arcgis server
|
||||||
|
// see: ArcGISCache.json
|
||||||
|
var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
|
||||||
|
layerInfo: layerInfo
|
||||||
|
});
|
||||||
|
|
||||||
|
t.ok( lods == layer.lods.length, 'proper number of "Levels of Detail" after initialization.' );
|
||||||
|
// restore the Array prototype
|
||||||
|
delete Array.prototype.foo;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user