diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index 19c38bc6d..514174b3a 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -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 ''; }); @@ -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); };