Skip to content

Commit

Permalink
Fix support to Multiple result in serach services
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Jul 14, 2017
1 parent cff72bf commit 51039aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion web/client/components/mapcontrols/search/SearchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let SearchResult = React.createClass({
}
let item = this.props.item;
return (
<div key={item.osm_id} className="search-result" onClick={this.onClick}>
<div key={item.osm_id} className="search-result" style={item.resultCssStyle} onClick={this.onClick}>
<div className="icon"> <img src={item.icon} /></div>
<div className="text-result-title">{get(item, this.props.displayName) || generateTemplateString(this.props.displayName || "")(item) }</div>
<small className="text-info">{this.props.subTitle && get(item, this.props.subTitle) || generateTemplateString(this.props.subTitle || "")(item) }</small>
Expand Down
2 changes: 1 addition & 1 deletion web/client/epics/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions web/client/utils/CoordinatesUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ const CoordinatesUtils = {

points[0].push(points[0][0]);
return points;
},
mergeToPolyGeom(features) {
if (features.length === 1) {
return features[0].geometry;
}
return {
type: "GeometryCollection",
geometries: features.map( ({geometry}) => geometry)
};
}
};

Expand Down

0 comments on commit 51039aa

Please sign in to comment.