diff --git a/src/ol/source/wmts.js b/src/ol/source/wmts.js index 684f9195d2..c5ce608850 100644 --- a/src/ol/source/wmts.js +++ b/src/ol/source/wmts.js @@ -292,6 +292,7 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) { * - style - {string} The name of the style * - format - {string} Image format for the layer. Default is the first * format returned in the GetCapabilities response. + * - crossOrigin - {string|null|undefined} Cross origin. Default is `undefined`. * @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found. * @api */ @@ -447,6 +448,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { tileGrid: tileGrid, style: style, dimensions: dimensions, - wrapX: wrapX + wrapX: wrapX, + crossOrigin: config['crossOrigin'] }; }; diff --git a/test/spec/ol/source/wmts.test.js b/test/spec/ol/source/wmts.test.js index c539fd23f0..7d734eb9bb 100644 --- a/test/spec/ol/source/wmts.test.js +++ b/test/spec/ol/source/wmts.test.js @@ -31,6 +31,16 @@ describe('ol.source.WMTS', function() { expect(options).to.be(null); }); + it('passes the crossOrigin option', function() { + var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + layer: 'BlueMarbleNextGeneration', + matrixSet: 'google3857', + crossOrigin: '' + }); + + expect(options.crossOrigin).to.be.eql(''); + }); + it('can create KVP options from spec/ol/format/wmts/ogcsample.xml', function() { var options = ol.source.WMTS.optionsFromCapabilities( @@ -59,6 +69,8 @@ describe('ol.source.WMTS', function() { expect(options.dimensions).to.eql({Time: '20110805'}); + expect(options.crossOrigin).to.be(undefined); + }); it('can create REST options from spec/ol/format/wmts/ogcsample.xml',