Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions plugins/LayerTree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class LayerTree extends React.Component {
const allowRemove = this.props.allowRemovingThemeLayers || ConfigUtils.getConfigProp("allowRemovingThemeLayers", this.props.theme) === true || layer.role !== LayerRole.THEME;
const allowReordering = ConfigUtils.getConfigProp("allowReorderingLayers", this.props.theme) === true && !this.state.filterinvisiblelayers;
const sortable = allowReordering && ConfigUtils.getConfigProp("preventSplittingGroupsWhenReordering", this.props.theme) === true;
const styles = this.props.showStyleSelector && layer.type === "wms" && path.length === 0 ? this.getLayerStyles(layer) : null;
const styles = this.props.showStyleSelector && layer.type === "wms" && path.length === 0 ? this.getLayersStyles([layer]) : null;
return (
<div className="layertree-item-container" data-id={JSON.stringify({layer: layer.id, path: path})} key={groupId}>
<div className={classnames(itemclasses)}>
Expand Down Expand Up @@ -848,9 +848,10 @@ class LayerTree extends React.Component {
getSelectedStyles = (layer) => {
return [...new Set((layer.params?.STYLES || "").split(",").filter(Boolean))];
};
getLayerStyles = (layer) => {
return layer?.sublayers?.reduce((styleList, sublayer) => {
Object.assign(styleList, this.getLayerStyles(sublayer.sublayers));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fix could be to just pass sublayer instead of sublayer.sublayers here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we would loose any style information that the root layer has. I'm not sure if it can have any, but did it like this just to be sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory it cannot have any - the WMS root layer is not represented in the QGIS layer tree, and does indeed not correspond to a QGIS Project layer.


getLayersStyles = (layers) => {
return layers?.reduce((styleList, sublayer) => {
Object.assign(styleList, this.getLayersStyles(sublayer.sublayers));
return Object.assign(styleList, sublayer.styles);
}, {});
};
Expand Down
Loading