diff --git a/externs/olx.js b/externs/olx.js index 29b2800488..a6cb26abb9 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -7325,6 +7325,17 @@ olx.source.ZoomifyOptions.prototype.tierSizeCalculation; olx.source.ZoomifyOptions.prototype.size; +/** + * Extent for the TileGrid that is created. Default sets the TileGrid in the + * fourth quadrant, meaning extent is `[0, -height, width, 0]`. To change the + * extent to the first quadrant (the default for OpenLayers 2) set the extent + * as `[0, 0, width, height]`. + * @type {ol.Extent|undefined} + * @api + */ +olx.source.ZoomifyOptions.prototype.extent; + + /** * Duration of the opacity transition for rendering. To disable the opacity * transition, pass `transition: 0`. diff --git a/src/ol/source/zoomify.js b/src/ol/source/zoomify.js index 0eddae086c..acc6b41a94 100644 --- a/src/ol/source/zoomify.js +++ b/src/ol/source/zoomify.js @@ -33,6 +33,7 @@ ol.source.Zoomify = function(opt_options) { var imageWidth = size[0]; var imageHeight = size[1]; + var extent = options.extent || [0, -size[1], size[0], 0]; var tierSizeInTiles = []; var tileSize = options.tileSize || ol.DEFAULT_TILE_SIZE; var tileSizeForTierSizeCalculation = tileSize; @@ -79,7 +80,6 @@ ol.source.Zoomify = function(opt_options) { } resolutions.reverse(); - var extent = [0, -size[1], size[0], 0]; var tileGrid = new ol.tilegrid.TileGrid({ tileSize: tileSize, extent: extent, diff --git a/test/spec/ol/source/zoomify.test.js b/test/spec/ol/source/zoomify.test.js index 72cde203db..4b9b2baef7 100644 --- a/test/spec/ol/source/zoomify.test.js +++ b/test/spec/ol/source/zoomify.test.js @@ -25,6 +25,13 @@ describe('ol.source.Zoomify', function() { size: size }); } + function getZoomifySourceWithExtentInFirstQuadrant() { + return new ol.source.Zoomify({ + url: zoomifyUrl, + size: size, + extent: [0, 0, size[0], size[1]] + }); + } function getIIPSource() { return new ol.source.Zoomify({ url: iipUrl, @@ -164,6 +171,31 @@ describe('ol.source.Zoomify', function() { expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]); } }); + + it('has expected extent', function() { + var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()]; + var expectedExtents = [ + [0, -size[1], size[0], 0], + [0, 0, size[0], size[1]] + ]; + for (var i = 0; i < sources.length; i++) { + var tileGrid = sources[i].getTileGrid(); + expect(tileGrid.getExtent()).to.eql(expectedExtents[i]); + } + }); + + it('has expected origin', function() { + var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()]; + var expectedOrigins = [ + [0, 0], + [0, size[1]] + ]; + for (var i = 0; i < sources.length; i++) { + var tileGrid = sources[i].getTileGrid(); + expect(tileGrid.getOrigin()).to.eql(expectedOrigins[i]); + } + }); + }); describe('tierSizeCalculation configuration', function() {