From 05b3fd63bf1b4d4653cd179a5fbb284361d2935d Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 24 Mar 2023 11:22:43 +0100 Subject: [PATCH] Minor bug fix (#1722) --- src/controls/search.js | 4 ++-- src/getattributes.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controls/search.js b/src/controls/search.js index b32e9ff8b..2e53892b9 100644 --- a/src/controls/search.js +++ b/src/controls/search.js @@ -128,7 +128,7 @@ const Search = function Search(options = {}) { let featureWkt; let coordWkt; if (res.length > 0) { - showFeatureInfo(res, layer.get('title'), getAttributes(res[0], layer)); + showFeatureInfo(res, layer.get('title'), getAttributes(res[0], layer, map)); } else if (geometryAttribute) { // Fallback if no geometry in response featureWkt = mapUtils.wktToFeature(data[geometryAttribute], projectionCode); @@ -139,7 +139,7 @@ const Search = function Search(options = {}) { } else if (geometryAttribute && layerName) { feature = mapUtils.wktToFeature(data[geometryAttribute], projectionCode); layer = viewer.getLayer(data[layerName]); - showFeatureInfo([feature], layer.get('title'), getAttributes(feature, layer)); + showFeatureInfo([feature], layer.get('title'), getAttributes(feature, layer, map)); } else if (titleAttribute && contentAttribute && geometryAttribute) { feature = mapUtils.wktToFeature(data[geometryAttribute], projectionCode); diff --git a/src/getattributes.js b/src/getattributes.js index a47fda06f..b51b1f2e3 100644 --- a/src/getattributes.js +++ b/src/getattributes.js @@ -197,7 +197,10 @@ function getAttributes(feature, layer, map) { featureinfoElement.appendChild(ulList); const attributes = feature.getProperties(); const geometryName = feature.getGeometryName(); - const attributeAlias = map.get('mapConfig').attributeAlias || []; + let attributeAlias = []; + if (map) { + attributeAlias = map.get('mapConfig').attributeAlias || []; + } delete attributes[geometryName]; let content; let attribute;