From 7b91c9c26fa0edcafcea4d886c4a83dfbe5fb84e Mon Sep 17 00:00:00 2001 From: dregade Date: Thu, 28 Jun 2012 17:16:22 +0200 Subject: [PATCH 1/2] fix size initialization and resolution/zoom usage --- lib/OpenLayers/Layer/Zoomify.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index 6179cccd14..b9ed54ff9b 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -105,6 +105,7 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { initializeZoomify: function( size ) { var imageSize = size.clone(); + this.size = size.clone(); var tiles = new OpenLayers.Size( Math.ceil( imageSize.w / this.standardTileSize ), Math.ceil( imageSize.h / this.standardTileSize ) @@ -195,10 +196,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { */ getURL: function (bounds) { bounds = this.adjustBounds(bounds); - var res = this.map.getResolution(); + var res = this.getServerResolution(); var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h)); - var z = this.map.getZoom(); + var z = this.getZoomForResolution( res ); var tileIndex = x + y * this.tierSizeInTiles[z].w + this.tileCountUpToTier[z]; var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) + @@ -219,10 +220,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { getImageSize: function() { if (arguments.length > 0) { var bounds = this.adjustBounds(arguments[0]); - var res = this.map.getResolution(); + var res = this.getServerResolution(); var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h)); - var z = this.map.getZoom(); + var z = this.getZoomForResolution( res ); var w = this.standardTileSize; var h = this.standardTileSize; if (x == this.tierSizeInTiles[z].w -1 ) { From 74f9a943cc0d84c673c73130e71981f9ca94afb2 Mon Sep 17 00:00:00 2001 From: dregade Date: Fri, 29 Jun 2012 09:22:54 +0200 Subject: [PATCH 2/2] fix serverResolutions if not provided --- lib/OpenLayers/Layer/Zoomify.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index b9ed54ff9b..d0b482ab29 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -133,14 +133,18 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { this.tierImageSize.reverse(); this.numberOfTiers = this.tierSizeInTiles.length; - + var resolutions = [1]; this.tileCountUpToTier = [0]; for (var i = 1; i < this.numberOfTiers; i++) { + resolutions.unshift(Math.pow(2, i)); this.tileCountUpToTier.push( this.tierSizeInTiles[i-1].w * this.tierSizeInTiles[i-1].h + this.tileCountUpToTier[i-1] ); } + if (!this.serverResolutions) { + this.serverResolutions = resolutions; + } }, /**