From 6746047fe2c2c8bf5b4678b93254e1714658cd9d Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Fri, 11 Dec 2020 13:35:51 +0100 Subject: [PATCH] Add setfeatures action --- .../common-map/src/fm-map/actions/map.actions.ts | 10 +++++++++- .../common-map/src/fm-map/effects/map.effects.ts | 13 +++++++++++++ .../common-map/src/fm-map/reducers/map.reducer.ts | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts index 2ba6176..aef56da 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -42,6 +42,7 @@ export const SETSTYLE = '[Map] SetStyle'; export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher'; export const CLEAR = '[Map] Clear'; export const SETREPLACEURL = '[Map] SetReplaceUrl'; +export const SETFEATURES = '[Map] SetFeatures' export class Clear implements Action { readonly type = CLEAR; @@ -256,6 +257,12 @@ export class SetReplaceUrl implements Action { constructor(public replaceUrl:boolean) {} } +export class SetFeatures implements Action { + readonly type = SETFEATURES; + + constructor(public features: Array) { } +} + export type Actions = SetMapState | Init | Clear @@ -291,5 +298,6 @@ export type Actions = SetMapState | DoQuery | SetStyle | ShowLayerSwitcher - | SetReplaceUrl; + | SetReplaceUrl + | SetFeatures; diff --git a/projects/common-map/src/fm-map/effects/map.effects.ts b/projects/common-map/src/fm-map/effects/map.effects.ts index 0e14bc1..de27cd7 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -150,6 +150,19 @@ export class MapEffects { return actions; })); + @Effect() + zoomToExtent2$: Observable = this.actions$.pipe( + ofType(mapActions.SETFEATURES), + map((action: mapActions.SetFeatures) => { + let extent = createEmpty(); + if (extent) { + for (let f of action.features) { + extend(extent, (f as Feature).getGeometry().getExtent()); + } + } + return new mapActions.SetExtent(extent); + })); + @Effect() hideMenu$: Observable = this.actions$.pipe( ofType(mapActions.STARTSEARCHSUCCESS), diff --git a/projects/common-map/src/fm-map/reducers/map.reducer.ts b/projects/common-map/src/fm-map/reducers/map.reducer.ts index e6e34d1..d0a3f8b 100644 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ b/projects/common-map/src/fm-map/reducers/map.reducer.ts @@ -138,6 +138,12 @@ export function reducer(state = initialState, action: mapActions.Actions | commo inSearch:false }); } + case mapActions.SETFEATURES: { + let a = action as mapActions.SetFeatures; + return tassign(state, { + features: a.features + }); + } case mapActions.SELECTFEATURE: { let a = action as mapActions.SelectFeature; return tassign(state, {