Layer.XYZ: support a subset of server resolutions, p=bbinet, r=me (closes #2909)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10903 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2010-11-17 12:51:22 +00:00
parent 9a3ca5fa7e
commit 5fe1b76e19
2 changed files with 38 additions and 2 deletions

View File

@@ -40,10 +40,19 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
* for a requested tile. For example, if you supply a zoomOffset
* of 3, when the map is at the zoom 0, tiles will be requested from
* level 3 of your cache. Default is 0 (assumes cache level and map
* zoom are equivalent).
* zoom are equivalent). Using <zoomOffset> is an alternative to
* setting <serverResolutions> if you only want to expose a subset
* of the server resolutions.
*/
zoomOffset: 0,
/**
* APIProperty: serverResolutions
* {Array} A list of all resolutions available on the server. Only set this
* property if the map resolutions differs from the server.
*/
serverResolutions: null,
/**
* Constructor: OpenLayers.Layer.XYZ
*
@@ -114,7 +123,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
/ (res * this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top)
/ (res * this.tileSize.h));
var z = this.map.getZoom() + this.zoomOffset;
var z = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.map.getZoom() + this.zoomOffset;
var url = this.url;
var s = '' + x + y + z;