Skip to content

Commit f3b0c2e

Browse files
committed
Merge pull request openlayers#558 from dregade/zoomify
fix size initialization and resolution/zoom usage. Thanks @dregade - this change makes fractional zoom work with Layer.Zoomify.
2 parents f686589 + 74f9a94 commit f3b0c2e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/OpenLayers/Layer/Zoomify.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {
105105
initializeZoomify: function( size ) {
106106

107107
var imageSize = size.clone();
108+
this.size = size.clone();
108109
var tiles = new OpenLayers.Size(
109110
Math.ceil( imageSize.w / this.standardTileSize ),
110111
Math.ceil( imageSize.h / this.standardTileSize )
@@ -132,14 +133,18 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {
132133
this.tierImageSize.reverse();
133134

134135
this.numberOfTiers = this.tierSizeInTiles.length;
135-
136+
var resolutions = [1];
136137
this.tileCountUpToTier = [0];
137138
for (var i = 1; i < this.numberOfTiers; i++) {
139+
resolutions.unshift(Math.pow(2, i));
138140
this.tileCountUpToTier.push(
139141
this.tierSizeInTiles[i-1].w * this.tierSizeInTiles[i-1].h +
140142
this.tileCountUpToTier[i-1]
141143
);
142144
}
145+
if (!this.serverResolutions) {
146+
this.serverResolutions = resolutions;
147+
}
143148
},
144149

145150
/**
@@ -195,10 +200,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {
195200
*/
196201
getURL: function (bounds) {
197202
bounds = this.adjustBounds(bounds);
198-
var res = this.map.getResolution();
203+
var res = this.getServerResolution();
199204
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
200205
var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));
201-
var z = this.map.getZoom();
206+
var z = this.getZoomForResolution( res );
202207

203208
var tileIndex = x + y * this.tierSizeInTiles[z].w + this.tileCountUpToTier[z];
204209
var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) +
@@ -219,10 +224,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {
219224
getImageSize: function() {
220225
if (arguments.length > 0) {
221226
var bounds = this.adjustBounds(arguments[0]);
222-
var res = this.map.getResolution();
227+
var res = this.getServerResolution();
223228
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
224229
var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));
225-
var z = this.map.getZoom();
230+
var z = this.getZoomForResolution( res );
226231
var w = this.standardTileSize;
227232
var h = this.standardTileSize;
228233
if (x == this.tierSizeInTiles[z].w -1 ) {

0 commit comments

Comments
 (0)