Skip to content

Commit

Permalink
Minor bug fix (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokd committed Mar 24, 2023
1 parent ab36426 commit 05b3fd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/getattributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05b3fd6

Please sign in to comment.