Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not copy 'visible' property for WMTS layers #5404

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion contribs/gmf/src/layertree/SyncLayertreeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ SyncLayertreeMap.prototype.createWMTSLayer_ = function(gmfLayerWMTS) {
minResolution,
maxResolution
).then((layer) => {
newLayer.setProperties(layer.getProperties());
this.layerHelper_.copyProperties(layer, newLayer, ['visible']);
});
return newLayer;
};
Expand Down
10 changes: 10 additions & 0 deletions contribs/gmf/src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,16 @@ PermalinkService.prototype.initLayers_ = function() {
}
this.gmfLayerBeingSwipe_.layer = treeCtrl.layer;
}

if (
treeCtrl.layer.getLayers &&
treeCtrl.layer.getLayers().item(0) &&
treeCtrl.layer.getLayers().item(0).get('layerNodeName') === 'ch.are.alpenkonvention'
adube marked this conversation as resolved.
Show resolved Hide resolved
) {
treeCtrl.layer.getLayers().item(0).on('change:visible', (e) => {
console.log(e);
});
}
}

if (treeCtrl.parent.node && parentGroupNode.mixed && groupNode.children == undefined) {
Expand Down
30 changes: 30 additions & 0 deletions src/map/LayerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ const GROUP_KEY = 'groupName';
const REFRESH_PARAM = 'random';


/**
* Copy each properties from a layer onto an other layer, with the
* option to exclude specific ones.
*
* @param {import("ol/layer/Layer.js").default} layerFrom The layer
* from which to copy the properties.
* @param {import("ol/layer/Layer.js").default} layerTo The layer onto
* which the properties are copied.
* @param {string[]=} opt_excludes A list of properties that should
* not be copied.
*/
LayerHelper.prototype.copyProperties = function(
layerFrom, layerTo, opt_excludes
) {
const properties = layerFrom.getProperties();
if (opt_excludes) {
const excludes = opt_excludes;
const keys = Object.keys(properties);
for (const key of keys) {
if (excludes.includes(key)) {
continue;
}
layerTo.set(key, properties[key]);
}
} else {
layerTo.setProperties(properties);
}
};


/**
* Create and return a basic WMS layer with only a source URL and a comma
* separated layers names (see {@link import("ol/source/ImageWMS.js").default}).
Expand Down