diff --git a/src/utils/legendmaker.js b/src/utils/legendmaker.js index ad2b93f35..1392c05ba 100644 --- a/src/utils/legendmaker.js +++ b/src/utils/legendmaker.js @@ -259,11 +259,8 @@ export const Legend = function Legend({ const style = viewer.getStyles()[styleName]; if (layer.get('type') !== 'WMS') { for (let i = 0; i < style.length; i += 1) { - let idStr; - if (style[i][0].id) { - idStr = style[i][0].id.toString(); - } - style[i][0].visible = activeThemes.includes(idStr || style[i][0].label); + const combinedStr = style[i][0].id?.toString() || style[i][0].label?.toString(); + style[i][0].visible = activeThemes.includes(combinedStr); } } }