From 82d6c531fc3afd9fe4a45d6e78e2d50aa74cd982 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 18 Feb 2022 09:34:50 +0100 Subject: [PATCH] fix: make print preview not crash when drag and dropped layer present; show theirs and other missing titles in legend (#1469) --- src/controls/print/print-legend.js | 4 +++- src/controls/print/print-resize.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index 91126f90a..4d21024f3 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -124,7 +124,9 @@ const LayerRow = function LayerRow(options) { const style = viewer.getStyle(layer.get('styleName')); if (style && style[0]) { content = getStyleContent(title, style); - } else if (!layer.get('type').includes('AGS')) { + } else if ((!layer.get('type')) || (layer.get('type').includes('AGS'))) { + content = getTitleWithIcon(title, ''); + } else { content = await getJSONContent(title); } return ` diff --git a/src/controls/print/print-resize.js b/src/controls/print/print-resize.js index d66ac0406..90187df6d 100644 --- a/src/controls/print/print-resize.js +++ b/src/controls/print/print-resize.js @@ -424,7 +424,7 @@ export default function PrintResize(options = {}) { // Remove styles instead? const styles = feature.getStyle(); const scale = 1; - if (styles) { + if (Array.isArray(styles)) { styles.forEach(style => { const image = style.getImage(); if (image) {