diff --git a/doc/offlinetilesenabler.md b/doc/offlinetilesenabler.md index 88afe87..0958d72 100644 --- a/doc/offlinetilesenabler.md +++ b/doc/offlinetilesenabler.md @@ -30,6 +30,9 @@ Methods | Returns | Description `loadFromFile(filename, callback)` | `callback( boolean, error)` | Reads a csv file into local tile cache. `estimateTileSize(callback)` | `callback(number)` | Retrieves one tile from a layer and then returns its size. `prepareForOffline(` `minLevel, maxLevel, extent, ` `reportProgress)` | `callback(number)` | Retrieves tiles and stores them in the local cache. See the "How To Use" section below to learn more about customizing the use of this method. +`getMinZoom(callback)` | `callback(number)` | Returns the minimum zoom level of the layer. This is the zoom level farther away from the earth. +`getMaxZoom(callback)` | `callback(number)` | Returns the maximum zoom level of the layer. This is the zoom level closest to the earth. + ###Properties Property | Description diff --git a/lib/tiles/OfflineTilesEnablerLayer.js b/lib/tiles/OfflineTilesEnablerLayer.js index 62a5d02..2b41ec8 100644 --- a/lib/tiles/OfflineTilesEnablerLayer.js +++ b/lib/tiles/OfflineTilesEnablerLayer.js @@ -190,17 +190,7 @@ define([ getMaxZoom: function(callback){ if(this._maxZoom == null){ - var lods = this.tileInfo.lods; - var length = this.tileInfo.lods.length; - var tempArr = []; - for(var i=0; i < length; i++){ - tempArr.push(lods[i].level); - if(i == length -1){ - tempArr.sortNumber(); - this._maxZoom = tempArr[i]; - callback(tempArr[i]); - } - } + this._maxZoom = this.tileInfo.lods[0].level; } else{ callback(this._maxZoom); @@ -215,17 +205,7 @@ define([ getMinZoom: function(callback){ if(this._minZoom == null){ - var lods = this.tileInfo.lods; - var length = this.tileInfo.lods.length; - var tempArr = []; - for(var i=0; i < length; i++){ - tempArr.push(lods[i].level); - if(i == length -1){ - tempArr.sortNumber(); - this._minZoom = tempArr[0]; - callback(tempArr[0]); - } - } + this._minZoom = this.tileInfo.lods[basemapLayer.tileInfo.lods.length-1].level; } else{ callback(this._minZoom); diff --git a/lib/tiles/offlineTilesEnabler.js b/lib/tiles/offlineTilesEnabler.js index 771699a..a6fcfaa 100644 --- a/lib/tiles/offlineTilesEnabler.js +++ b/lib/tiles/offlineTilesEnabler.js @@ -239,6 +239,35 @@ define([ layer._tilesCore._loadFromFile(file,this.offline.store,callback); }; + /** + * Returns the maximum zoom level for this layer + * @param callback number + */ + layer.getMaxZoom = function(callback){ + + if(this._maxZoom == null){ + this._maxZoom = layer.tileInfo.lods[0].level; + } + else{ + callback(this._maxZoom); + } + + }, + + /** + * Returns the minimum zoom level for this layer + * @param callback number + */ + layer.getMinZoom = function(callback){ + + if(this._minZoom == null){ + this._minZoom = layer.tileInfo.lods[basemapLayer.tileInfo.lods.length-1].level; + } + else{ + callback(this._minZoom); + } + }, + /* internal methods */ /**