Skip to content

Commit

Permalink
Merge pull request #956 from geoadmin/bug_PB-705_aggregate_layer_feat…
Browse files Browse the repository at this point in the history
…ure_search

PB-705 : fix feature search on aggregate layers - #patch
  • Loading branch information
pakb authored Jun 25, 2024
2 parents aec1bb3 + 8048ae1 commit f4612f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/api/layers/GeoAdminAggregateLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export default class GeoAdminAggregateLayer extends GeoAdminLayer {
* is `[]`
* @param {Boolean} [layerData.hasLegend=false] Define if this layer has a legend that can be
* shown to users to explain its content. Default is `false`
* @param {Boolean} [layerData.searchable=false] Define if this layer's features can be searched
* through the search bar. Default is `false`
* @param {[AggregateSubLayer]} layerData.subLayers
* @throws InvalidLayerDataError if no `layerData` is given or if it is invalid
*/
Expand All @@ -97,6 +99,7 @@ export default class GeoAdminAggregateLayer extends GeoAdminLayer {
topics = [],
subLayers = [],
hasLegend = false,
searchable = false,
} = layerData
super({
name,
Expand All @@ -113,6 +116,7 @@ export default class GeoAdminAggregateLayer extends GeoAdminLayer {
topics,
timeConfig,
hasLegend,
searchable,
})
this.subLayers = [...subLayers]
}
Expand Down
1 change: 1 addition & 0 deletions src/api/layers/layers.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const generateClassForLayerConfig = (layerConfig, id, allOtherLayers, lang) => {
topics,
subLayers,
hasLegend: !!hasLegend,
searchable,
})

break
Expand Down
6 changes: 5 additions & 1 deletion src/api/search.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ function parseLocationResult(result, outputProjection) {
extent.push(bottomLeft, topRight)
}
}
// when no zoom and no extent are given, we go 1:25'000 map by default
if (!zoom && extent.length === 0) {
zoom = outputProjection.get1_25000ZoomLevel()
}
return {
resultType: SearchResultTypes.LOCATION,
id: featureId,
Expand Down Expand Up @@ -248,7 +252,7 @@ async function searchLayerFeatures(outputProjection, queryString, layer, lang, c
resultWithAttrs.map((layerFeature) => {
const layerContent = parseLayerResult(layerFeature)
const locationContent = parseLocationResult(layerFeature, outputProjection)
const title = `<strong>${layer.name}</strong><br/>${layerContent.title}&nbsp;<small>${layerContent.description}</small>`
const title = `<strong>${layer.name}</strong><br/>${layerContent.title}`
return {
...layerContent,
...locationContent,
Expand Down

0 comments on commit f4612f9

Please sign in to comment.