From 16715f41f6178a1673a28d4ec56e4202839d6c4d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 21 May 2009 14:50:43 +0000 Subject: [PATCH] Using the cross-browser util method for array indexOf in the TileCache layer. r=crschmidt (closes #2099) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9402 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/TileCache.js | 4 +++- tests/Layer/TileCache.html | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/TileCache.js b/lib/OpenLayers/Layer/TileCache.js index 7058c5da03..ddf6a7c714 100644 --- a/lib/OpenLayers/Layer/TileCache.js +++ b/lib/OpenLayers/Layer/TileCache.js @@ -105,7 +105,9 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, { var size = this.tileSize; var tileX = Math.round((bounds.left - bbox.left) / (res * size.w)); var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h)); - var tileZ = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom(); + var tileZ = this.serverResolutions != null ? + OpenLayers.Util.indexOf(this.serverResolutions, res) : + this.map.getZoom(); /** * Zero-pad a positive integer. * number - {Int} diff --git a/tests/Layer/TileCache.html b/tests/Layer/TileCache.html index 216979e741..d24a44acc9 100644 --- a/tests/Layer/TileCache.html +++ b/tests/Layer/TileCache.html @@ -159,7 +159,8 @@ layer.serverResolutions = [14,13,12,11,10]; tileurl = layer.getURL(new OpenLayers.Bounds(0,0,0,0)); level = parseInt(tileurl.split('/')[2]); - t.eq(layer.serverResolutions.indexOf(map.getResolution()), level, "Tile zoom level is correct with serverResolutions"); + var gotLevel = OpenLayers.Util.indexOf(layer.serverResolutions, map.getResolution()); + t.eq(gotLevel, level, "Tile zoom level is correct with serverResolutions"); map.destroy(); }