From 6b115e2763c6fe257c745e63b9f3233699817dfc Mon Sep 17 00:00:00 2001 From: jokd Date: Thu, 7 Dec 2023 09:46:29 +0100 Subject: [PATCH] infowindow for search Use infowindow for search result if set --- src/controls/search.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/controls/search.js b/src/controls/search.js index 8724e8140..76c89563e 100644 --- a/src/controls/search.js +++ b/src/controls/search.js @@ -3,7 +3,6 @@ import Point from 'ol/geom/Point'; import Awesomplete from 'awesomplete'; import { Component, Element as El, Button, Collapse, CollapseHeader, dom } from '../ui'; import generateUUID from '../utils/generateuuid'; -import getAttributes from '../getattributes'; import getCenter from '../geometry/getcenter'; import getFeature from '../getfeature'; import mapUtils from '../maputils'; @@ -134,7 +133,8 @@ const Search = function Search(options = {}) { let featureWkt; let coordWkt; if (res.length > 0) { - showFeatureInfo(res, layer.get('title'), getAttributes(res[0], layer, map)); + const featLayerName = layer.get('name'); + featureInfo.showFeatureInfo({ feature: res, layerName: featLayerName }, { maxZoomLevel }); } else if (geometryAttribute) { // Fallback if no geometry in response featureWkt = mapUtils.wktToFeature(data[geometryAttribute], projectionCode); @@ -144,8 +144,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, map)); + featureInfo.showFeatureInfo({ feature: [feature], layerName }, { maxZoomLevel }); } else if (titleAttribute && contentAttribute && geometryAttribute) { feature = mapUtils.wktToFeature(data[geometryAttribute], projectionCode);