From 18710eae84329c42162da51e218b6aa7395d4540 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Fri, 14 Jul 2017 15:39:48 +0200 Subject: [PATCH] Fix support to Multiple result in serach services --- .../components/mapcontrols/search/SearchResult.jsx | 2 +- web/client/epics/search.js | 2 +- web/client/utils/CoordinatesUtils.js | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/client/components/mapcontrols/search/SearchResult.jsx b/web/client/components/mapcontrols/search/SearchResult.jsx index 7478197009..49ba21b0aa 100644 --- a/web/client/components/mapcontrols/search/SearchResult.jsx +++ b/web/client/components/mapcontrols/search/SearchResult.jsx @@ -47,7 +47,7 @@ class SearchResult extends React.Component { } let item = this.props.item; return ( -
+
{get(item, this.props.displayName) || generateTemplateString(this.props.displayName || "")(item) }
{this.props.subTitle && get(item, this.props.subTitle) || generateTemplateString(this.props.subTitle || "")(item) } diff --git a/web/client/epics/search.js b/web/client/epics/search.js index df8bfca364..62d20d7ec9 100644 --- a/web/client/epics/search.js +++ b/web/client/epics/search.js @@ -93,7 +93,7 @@ const searchItemSelected = action$ => // retrieve geometry from geomService or pass the item directly return Rx.Observable.fromPromise( API.Utils.getService(item.__SERVICE__.geomService.type)("", assign( {}, item.__SERVICE__.geomService.options, { staticFilter } )) - .then(res => assign({}, item, {geometry: res[0].geometry} ) ) + .then(res => assign({}, item, {geometry: CoordinatesUtils.mergeToPolyGeom(res)} ) ) ); } return Rx.Observable.of(action.item); diff --git a/web/client/utils/CoordinatesUtils.js b/web/client/utils/CoordinatesUtils.js index 68b3b5d664..471df4bf2b 100644 --- a/web/client/utils/CoordinatesUtils.js +++ b/web/client/utils/CoordinatesUtils.js @@ -389,6 +389,15 @@ const CoordinatesUtils = { } default: return []; } + }, + mergeToPolyGeom(features) { + if (features.length === 1) { + return features[0].geometry; + } + return { + type: "GeometryCollection", + geometries: features.map( ({geometry}) => geometry) + }; } };