Skip to content

Commit

Permalink
feat: make the print legend respect theme visibility of thematicstyli…
Browse files Browse the repository at this point in the history
…ng layers (#1969)
  • Loading branch information
Grammostola committed Mar 26, 2024
1 parent 1e51a6c commit 8400922
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/controls/print/print-legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,14 @@ const LayerRow = function LayerRow(options) {
return getTitleWithIcon(title, getStyleIcon(style[0]));
}

const hasThematicStyle = (layer.get('thematicStyling') === true);
const children = style.map((thisStyle, index) => {
if (!isHidden(thisStyle)) {
const styleIcon = getStyleIcon(thisStyle);
const rowTitle = thisStyle[0].label ? thisStyle[0].label : index + 1;
return getListItem(rowTitle, styleIcon);
if (!(isHidden(thisStyle))) {
if ((!(hasThematicStyle)) || (!(thisStyle[0]?.visible === false))) {
const styleIcon = getStyleIcon(thisStyle);
const rowTitle = thisStyle[0].label ? thisStyle[0].label : index + 1;
return getListItem(rowTitle, styleIcon);
}
}
return '';
});
Expand Down Expand Up @@ -205,11 +208,16 @@ const LayerRow = function LayerRow(options) {
return getTitleWithIcon(title, icon);
}

const rules = json.Legend[0].rules.map((rule, index) => {
const ruleImageUrl = `${getLegendGraphicUrl}&rule=${rule.name}`;
const rowTitle = rule.title ? rule.title : index + 1;
return getListItem(rowTitle, ruleImageUrl, true);
});
const thematicStyle = (layer.get('thematicStyling') === true) ? viewer.getStyle(layer.get('styleName')) : undefined;
const rules = json.Legend[0].rules.reduce((okRules, rule, index) => {
if (!(layer.get('thematicStyling')) || thematicStyle[0]?.thematic[index]?.visible) {
const ruleImageUrl = `${getLegendGraphicUrl}&rule=${rule.name}`;
const rowTitle = rule.title ? rule.title : index + 1;
okRules.push(getListItem(rowTitle, ruleImageUrl, true));
}
return okRules;
}, []);

return getTitleWithChildren(title, rules);
};

Expand Down

0 comments on commit 8400922

Please sign in to comment.