diff --git a/src/openseadragon.js b/src/openseadragon.js index 73fb912b..ef002f37 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -163,6 +163,10 @@ * The colors of grids in debug mode. Each tiled image's grid uses a consecutive color. * If there are more tiled images than provided colors, the color vector is recycled. * + * @property {Boolean} [silenceMultiImageWarnings=false] + * Silences warnings when calling viewport coordinate functions with multi-image. + * Useful when you're overlaying multiple images on top of one another. + * * @property {Number} [blendTime=0] * Specifies the duration of animation as higher or lower level tiles are * replacing the existing tile. @@ -1370,7 +1374,9 @@ function OpenSeadragon( options ){ //DEVELOPER SETTINGS debugMode: false, - debugGridColor: ['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666'] + debugGridColor: ['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666'], + silenceMultiImageWarnings: false + }, diff --git a/src/viewer.js b/src/viewer.js index b4199a42..8d7be6ae 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -366,23 +366,24 @@ $.Viewer = function( options ) { // Create the viewport this.viewport = new $.Viewport({ - containerSize: THIS[ this.hash ].prevContainerSize, - springStiffness: this.springStiffness, - animationTime: this.animationTime, - minZoomImageRatio: this.minZoomImageRatio, - maxZoomPixelRatio: this.maxZoomPixelRatio, - visibilityRatio: this.visibilityRatio, - wrapHorizontal: this.wrapHorizontal, - wrapVertical: this.wrapVertical, - defaultZoomLevel: this.defaultZoomLevel, - minZoomLevel: this.minZoomLevel, - maxZoomLevel: this.maxZoomLevel, - viewer: this, - degrees: this.degrees, - flipped: this.flipped, - navigatorRotate: this.navigatorRotate, - homeFillsViewer: this.homeFillsViewer, - margins: this.viewportMargins + containerSize: THIS[ this.hash ].prevContainerSize, + springStiffness: this.springStiffness, + animationTime: this.animationTime, + minZoomImageRatio: this.minZoomImageRatio, + maxZoomPixelRatio: this.maxZoomPixelRatio, + visibilityRatio: this.visibilityRatio, + wrapHorizontal: this.wrapHorizontal, + wrapVertical: this.wrapVertical, + defaultZoomLevel: this.defaultZoomLevel, + minZoomLevel: this.minZoomLevel, + maxZoomLevel: this.maxZoomLevel, + viewer: this, + degrees: this.degrees, + flipped: this.flipped, + navigatorRotate: this.navigatorRotate, + homeFillsViewer: this.homeFillsViewer, + margins: this.viewportMargins, + silenceMultiImageWarnings: this.silenceMultiImageWarnings }); this.viewport._setContentBounds(this.world.getHomeBounds(), this.world.getContentFactor()); diff --git a/src/viewport.js b/src/viewport.js index 513d02fb..be350af9 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -54,6 +54,7 @@ * @param {Number} [options.maxZoomLevel] - See maxZoomLevel in {@link OpenSeadragon.Options}. * @param {Number} [options.degrees] - See degrees in {@link OpenSeadragon.Options}. * @param {Boolean} [options.homeFillsViewer] - See homeFillsViewer in {@link OpenSeadragon.Options}. + * @param {Boolean} [options.silenceMultiImageWarnings] - See silenceMultiImageWarnings in {@link OpenSeadragon.Options}. */ $.Viewport = function( options ) { @@ -96,19 +97,20 @@ $.Viewport = function( options ) { viewer: null, //configurable options - springStiffness: $.DEFAULT_SETTINGS.springStiffness, - animationTime: $.DEFAULT_SETTINGS.animationTime, - minZoomImageRatio: $.DEFAULT_SETTINGS.minZoomImageRatio, - maxZoomPixelRatio: $.DEFAULT_SETTINGS.maxZoomPixelRatio, - visibilityRatio: $.DEFAULT_SETTINGS.visibilityRatio, - wrapHorizontal: $.DEFAULT_SETTINGS.wrapHorizontal, - wrapVertical: $.DEFAULT_SETTINGS.wrapVertical, - defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel, - minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel, - maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel, - degrees: $.DEFAULT_SETTINGS.degrees, - flipped: $.DEFAULT_SETTINGS.flipped, - homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer + springStiffness: $.DEFAULT_SETTINGS.springStiffness, + animationTime: $.DEFAULT_SETTINGS.animationTime, + minZoomImageRatio: $.DEFAULT_SETTINGS.minZoomImageRatio, + maxZoomPixelRatio: $.DEFAULT_SETTINGS.maxZoomPixelRatio, + visibilityRatio: $.DEFAULT_SETTINGS.visibilityRatio, + wrapHorizontal: $.DEFAULT_SETTINGS.wrapHorizontal, + wrapVertical: $.DEFAULT_SETTINGS.wrapVertical, + defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel, + minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel, + maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel, + degrees: $.DEFAULT_SETTINGS.degrees, + flipped: $.DEFAULT_SETTINGS.flipped, + homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer, + silenceMultiImageWarnings: $.DEFAULT_SETTINGS.silenceMultiImageWarnings }, options ); @@ -1170,8 +1172,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.viewportToImageCoordinates] is not accurate ' + - 'with multi-image; use TiledImage.viewportToImageCoordinates instead.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.viewportToImageCoordinates] is not accurate ' + + 'with multi-image; use TiledImage.viewportToImageCoordinates instead.'); + } } else if (count === 1) { // It is better to use TiledImage.viewportToImageCoordinates // because this._contentBoundsNoRotate can not be relied on @@ -1214,8 +1218,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' + - 'with multi-image; use TiledImage.imageToViewportCoordinates instead.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' + + 'with multi-image; use TiledImage.imageToViewportCoordinates instead.'); + } } else if (count === 1) { // It is better to use TiledImage.viewportToImageCoordinates // because this._contentBoundsNoRotate can not be relied on @@ -1256,8 +1262,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.imageToViewportRectangle] is not accurate ' + - 'with multi-image; use TiledImage.imageToViewportRectangle instead.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.imageToViewportRectangle] is not accurate ' + + 'with multi-image; use TiledImage.imageToViewportRectangle instead.'); + } } else if (count === 1) { // It is better to use TiledImage.imageToViewportRectangle // because this._contentBoundsNoRotate can not be relied on @@ -1304,8 +1312,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.viewportToImageRectangle] is not accurate ' + - 'with multi-image; use TiledImage.viewportToImageRectangle instead.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.viewportToImageRectangle] is not accurate ' + + 'with multi-image; use TiledImage.viewportToImageRectangle instead.'); + } } else if (count === 1) { // It is better to use TiledImage.viewportToImageCoordinates // because this._contentBoundsNoRotate can not be relied on @@ -1469,8 +1479,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.viewportToImageZoom] is not ' + - 'accurate with multi-image.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.viewportToImageZoom] is not ' + + 'accurate with multi-image.'); + } } else if (count === 1) { // It is better to use TiledImage.viewportToImageZoom // because this._contentBoundsNoRotate can not be relied on @@ -1503,8 +1515,10 @@ $.Viewport.prototype = { if (this.viewer) { var count = this.viewer.world.getItemCount(); if (count > 1) { - $.console.error('[Viewport.imageToViewportZoom] is not accurate ' + - 'with multi-image.'); + if (!this.silenceMultiImageWarnings) { + $.console.error('[Viewport.imageToViewportZoom] is not accurate ' + + 'with multi-image.'); + } } else if (count === 1) { // It is better to use TiledImage.imageToViewportZoom // because this._contentBoundsNoRotate can not be relied on