Skip to content

Commit

Permalink
Matrix & Res able to use options from config
Browse files Browse the repository at this point in the history
  • Loading branch information
sppant committed Dec 13, 2016
1 parent ff98527 commit 08712b2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions web/client/components/map/openlayers/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,20 @@ function getWMSURLs( urls ) {
return urls.map((url) => url.split("\?")[0]);
}

function getMatrixId(options) {
let matrixIds = new Array(22);
for (let z = 0; z < 22; ++z) {
// generate matrixIds arrays for this WMTS
matrixIds[z] = options.tileMatrixPrefix + z;
}
return matrixIds;
}

Layers.registerType('wmts', {
create: (options) => {
const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
const queryParameters = wmtsToOpenlayersOptions(options) || {};
urls.forEach(url => SecurityUtils.addAuthenticationParameter(url, queryParameters));
let matrixIds = new Array(22);
for (let z = 0; z < 22; ++z) {
// generate matrixIds arrays for this WMTS
matrixIds[z] = options.tileMatrixPrefix + z;
}
return new ol.layer.Tile({
opacity: options.opacity !== undefined ? options.opacity : 1,
source: new ol.source.WMTS(objectAssign({
Expand All @@ -51,8 +55,8 @@ Layers.registerType('wmts', {
format: 'image/png',
tileGrid: new ol.tilegrid.WMTS({
origin: [options.originY, options.originX],
resolutions: mapUtils.getResolutions(),
matrixIds: matrixIds
resolutions: options.resolutions || mapUtils.getResolutions(),
matrixIds: options.matrixIds || getMatrixId(options)
}),
style: '',
wrapX: true
Expand Down

0 comments on commit 08712b2

Please sign in to comment.