@@ -24,7 +24,7 @@ import { FeatureLike } from "ol/Feature";
2424import { Cluster } from "ol/source" ;
2525import BaseObject from "ol/Object" ;
2626import { getCenter } from "ol/extent" ;
27- import { getSinglePointStyle , isCoordinateInsideFeature , isLayerClustered } from "./MapUtils" ;
27+ import { getHighlightStyle , getSinglePointStyle , isCoordinateInsideFeature , isLayerClustered } from "./MapUtils" ;
2828import Static from "ol/source/ImageStatic" ;
2929
3030class Map {
@@ -70,6 +70,11 @@ class Map {
7070 */
7171 private planOfRealVectorLayer : VectorLayer < VectorSource > ;
7272
73+ /**
74+ * A layer to draw highlighted feature (when active in FeatureInfo dialog)
75+ */
76+ private highLightedFeatureLayer : VectorLayer < VectorSource > ;
77+
7378 /**
7479 * Callback function to process features returned from GetFeatureInfo requests
7580 *
@@ -90,6 +95,7 @@ class Map {
9095 const nonClusteredOverlayLayerGroup = this . createNonClusteredOverlayLayerGroup ( mapConfig ) ;
9196 this . planRealDiffVectorLayer = Map . createPlanRealDiffVectorLayer ( ) ;
9297 this . planOfRealVectorLayer = Map . createPlanOfRealVectorLayer ( ) ;
98+ this . highLightedFeatureLayer = Map . createHighLightLayer ( ) ;
9399
94100 const resolutions = [ 256 , 128 , 64 , 32 , 16 , 8 , 4 , 2 , 1 , 0.5 , 0.25 , 0.125 , 0.0625 ] ;
95101 const projection = this . getProjection ( ) ;
@@ -109,11 +115,12 @@ class Map {
109115 nonClusteredOverlayLayerGroup ,
110116 this . planRealDiffVectorLayer ,
111117 this . planOfRealVectorLayer ,
118+ this . highLightedFeatureLayer ,
112119 ] ,
113120 controls : this . getControls ( ) ,
114121 view,
115122 } ) ;
116-
123+ this . highLightedFeatureLayer . setVisible ( true ) ;
117124 this . overViewMap = new OverviewMap ( {
118125 className : "ol-overviewmap" ,
119126 layers : [
@@ -266,6 +273,21 @@ class Map {
266273 } ) ;
267274 }
268275
276+ /**
277+ *
278+ * @param feature Target feature to be highlighted
279+ */
280+ highlightFeature ( feature : Feature , mapConfig : MapConfig ) {
281+ this . clearHighlightLayer ( ) ;
282+ const olFeature = new OlFeature ( {
283+ geometry : feature . getProperties ( ) . geometry ,
284+ name : "HiglightedFeature" ,
285+ } ) ;
286+
287+ this . highLightedFeatureLayer . setStyle ( getHighlightStyle ( feature , mapConfig ) ) ;
288+ this . highLightedFeatureLayer . getSource ( ) ?. addFeature ( olFeature ) ;
289+ }
290+
269291 showAllPlanAndRealDifferences ( realLayer : VectorLayer < VectorSource > , planLayer : VectorLayer < VectorSource > ) {
270292 let realFeatures : FeatureLike [ ] ,
271293 planFeatures : FeatureLike [ ] = [ ] ;
@@ -322,10 +344,17 @@ class Map {
322344 }
323345 }
324346
347+ private static createHighLightLayer ( ) {
348+ const highLightLayerSource = new VectorSource ( { } ) ;
349+ return new VectorLayer ( {
350+ source : highLightLayerSource ,
351+ } ) ;
352+ }
353+
325354 private static createPlanRealDiffVectorLayer ( ) {
326- const planRealDiffVectorLayer = new VectorSource ( { } ) ;
355+ const planRealDiffVectorLayerSource = new VectorSource ( { } ) ;
327356 return new VectorLayer ( {
328- source : planRealDiffVectorLayer ,
357+ source : planRealDiffVectorLayerSource ,
329358 // Point style
330359 style : new Style ( {
331360 image : new Circle ( {
@@ -348,9 +377,9 @@ class Map {
348377 }
349378
350379 private static createPlanOfRealVectorLayer ( ) {
351- const planOfRealVectorLayer = new VectorSource ( { } ) ;
380+ const planOfRealVectorLayerSource = new VectorSource ( { } ) ;
352381 return new VectorLayer ( {
353- source : planOfRealVectorLayer ,
382+ source : planOfRealVectorLayerSource ,
354383 // Point style
355384 style : new Style ( {
356385 image : new Circle ( {
@@ -406,6 +435,10 @@ class Map {
406435 this . planOfRealVectorLayer . getSource ( ) ! . clear ( ) ;
407436 }
408437
438+ clearHighlightLayer ( ) {
439+ this . highLightedFeatureLayer . getSource ( ) ! . clear ( ) ;
440+ }
441+
409442 applyProjectFilters ( overlayConfig : LayerConfig , projectId : string ) {
410443 const { sourceUrl } = overlayConfig ;
411444 const filter_field = "responsible_entity_name" ;
0 commit comments