Skip to content

Commit

Permalink
Fix for hidden styles in print legend (origo-map#1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokd authored Mar 1, 2023
1 parent a47af1d commit 5331fd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/controls/print/print-legend.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ImageArcGISRest, ImageWMS } from 'ol/source';
import { Component } from '../../ui';
import { renderSvgIcon } from '../../utils/legendmaker';
import { isHidden, renderSvgIcon } from '../../utils/legendmaker';

/**
* More information: https://developers.arcgis.com/rest/services-reference/enterprise/legend-map-service-.htm
Expand Down Expand Up @@ -168,9 +168,12 @@ const LayerRow = function LayerRow(options) {
}

const children = style.map((thisStyle, index) => {
const styleIcon = getStyleIcon(thisStyle);
const rowTitle = thisStyle[0].label ? thisStyle[0].label : index + 1;
return getListItem(rowTitle, styleIcon);
if (!isHidden(thisStyle)) {
const styleIcon = getStyleIcon(thisStyle);
const rowTitle = thisStyle[0].label ? thisStyle[0].label : index + 1;
return getListItem(rowTitle, styleIcon);
}
return '';
});
return getTitleWithChildren(title, children);
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/legendmaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { renderIcon, renderSvg } from './legendrender';

const size = 24;

const isHidden = function isHidden(arr) {
export const isHidden = function isHidden(arr) {
const hiddenItem = arr.find(item => item.hidden);
if (hiddenItem) {
if (hiddenItem.hidden === true) {
Expand Down

0 comments on commit 5331fd3

Please sign in to comment.