diff --git a/src/imagetilesource.js b/src/imagetilesource.js index a7f025b3..e398296b 100644 --- a/src/imagetilesource.js +++ b/src/imagetilesource.js @@ -46,6 +46,7 @@ */ $.ImageTileSource = function (options) { + this.options = options; $.TileSource.apply(this, [options]); }; @@ -64,13 +65,13 @@ /** * * @function - * @param {Image} image - the actual image + * @param {Object} options - the options * @param {String} dataUrl - the url the image was retreived from, if any. * @return {Object} options - A dictionary of keyword arguments sufficient * to configure this tile sources constructor. */ - configure: function (image, dataUrl) { - return image; + configure: function (options, dataUrl) { + return options; }, /** * Responsible for retrieving, and caching the @@ -83,6 +84,13 @@ var image = new Image(); var _this = this; + if (this.options.crossOriginPolicy) { + image.crossOriginPolicy = this.options.crossOriginPolicy; + } + if (this.options.ajaxWithCredentials) { + image.useCredentials = this.options.ajaxWithCredentials; + } + image.addEventListener('load', function () { _this.width = image.naturalWidth; _this.height = image.naturalHeight; diff --git a/src/viewer.js b/src/viewer.js index c763cf68..f59f9d1f 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2045,6 +2045,7 @@ function getTileSourceImplementation( viewer, tileSource, successCallback, //If its still a string it means it must be a url at this point tileSource = new $.TileSource({ url: tileSource, + crossOriginPolicy: viewer.crossOriginPolicy, ajaxWithCredentials: viewer.ajaxWithCredentials, success: function( event ) { successCallback( event.tileSource ); @@ -2054,7 +2055,10 @@ function getTileSourceImplementation( viewer, tileSource, successCallback, failCallback( event ); } ); - } else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ) { + } else if ($.isPlainObject(tileSource) || tileSource.nodeType) { + if (!tileSource.crossOriginPolicy && viewer.crossOriginPolicy) { + tileSource.crossOriginPolicy = viewer.crossOriginPolicy; + } if (tileSource.ajaxWithCredentials === undefined) { tileSource.ajaxWithCredentials = viewer.ajaxWithCredentials; }