Skip to content

Commit

Permalink
infowindow for search
Browse files Browse the repository at this point in the history
Use infowindow for search result if set
  • Loading branch information
jokd committed Dec 7, 2023
1 parent dd20f84 commit 6b115e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 6b115e2

Please sign in to comment.