From e9fe41e4e9d7b91963d4955172c541cd289886f5 Mon Sep 17 00:00:00 2001 From: Grammostola Date: Fri, 27 Oct 2023 15:51:45 +0200 Subject: [PATCH 1/2] fix: only issue getlegendgraphic requests for wms layers --- src/controls/print/print-legend.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index 7b7039967..78e0a417f 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -245,9 +245,12 @@ const LayerRow = function LayerRow(options) { content = getTitleWithIcon(title, ''); } else if (layer.get('type').includes('AGS') || /\/arcgis\/services\/[^/]+\/[^/]+\/MapServer\/WMSServer/.test(getOneUrl(layer))) { content = await getAGSJSONContent(title, layer.get('id')); - } else { + } else if (layer.get('type').includes('WMS')) { content = await getWMSJSONContent(title); } + if (content === '') { + content = getTitleWithIcon(title, ''); + } return `
  • From d3df46282269b8cc20fd087d0a281c5118e5a808 Mon Sep 17 00:00:00 2001 From: Grammostola Date: Mon, 30 Oct 2023 09:02:44 +0100 Subject: [PATCH 2/2] fix: refactor block --- src/controls/print/print-legend.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index 78e0a417f..19c38bc6d 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -237,19 +237,17 @@ const LayerRow = function LayerRow(options) { async render() { const title = layer.get('title') || 'Titel saknas'; let content = ''; - const style = viewer.getStyle(layer.get('styleName')); if (style && style[0] && (!style[0][0].extendedLegend)) { content = getStyleContent(title, style); - } else if (!layer.get('type') || layer.get('styleName') === 'origoStylefunction') { - content = getTitleWithIcon(title, ''); - } else if (layer.get('type').includes('AGS') || /\/arcgis\/services\/[^/]+\/[^/]+\/MapServer\/WMSServer/.test(getOneUrl(layer))) { - content = await getAGSJSONContent(title, layer.get('id')); - } else if (layer.get('type').includes('WMS')) { - content = await getWMSJSONContent(title); - } - if (content === '') { + } else { content = getTitleWithIcon(title, ''); + const lType = layer.get('type'); + if ((lType && lType.includes('AGS')) || /\/arcgis\/services\/[^/]+\/[^/]+\/MapServer\/WMSServer/.test(getOneUrl(layer))) { + content = await getAGSJSONContent(title, layer.get('id')); + } else if (lType && lType.includes('WMS')) { + content = await getWMSJSONContent(title); + } } return `