Merge pull request #558 from dregade/zoomify

fix size initialization and resolution/zoom usage. Thanks @dregade - this change makes fractional zoom work with Layer.Zoomify.
This commit is contained in:
ahocevar
2012-06-29 05:27:08 -07:00

View File

@@ -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 )
@@ -132,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;
}
},
/**
@@ -195,10 +200,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 +224,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 ) {