From a782d8ebe93f3bae98d05471c435162c775a4319 Mon Sep 17 00:00:00 2001 From: Mark van der Wal Date: Wed, 16 Dec 2020 23:01:59 +0100 Subject: [PATCH] add clearlayers action --- projects/common-map/src/fm-map/actions/map.actions.ts | 8 ++++++++ projects/common-map/src/fm-map/reducers/map.reducer.ts | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) 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 0ded481..17c8c2a 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -33,6 +33,7 @@ export const SETVISIBILITY = '[Map] SetVisibility'; export const SETOPACITY = '[Map] SetOpacity'; export const SETLAYERINDEX = '[Map] SetLayerIndex'; export const REMOVELAYER = '[Map] RemoveLayer'; +export const CLEARLAYERS = '[Map] ClearLayers'; export const LOADBASELAYERS = '[Map] LoadLayers'; export const LOADBASELAYERSSUCCESS = '[Map] LoadLayersSuccess'; export const SELECTBASELAYER = '[Map] SelectBaseLayers'; @@ -212,6 +213,12 @@ export class RemoveLayer implements Action { constructor(public itemLayer: IItemLayer) { } } +export class ClearLayers implements Action { + readonly type = CLEARLAYERS; + + constructor() { } +} + export class LoadBaseLayers implements Action { readonly type = LOADBASELAYERS; @@ -292,6 +299,7 @@ export type Actions = SetMapState | SetTimeSpan | AddLayer | RemoveLayer + | ClearLayers | SetVisibility | SetOpacity | SetLayerIndex 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 72182c9..695fb97 100644 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ b/projects/common-map/src/fm-map/reducers/map.reducer.ts @@ -328,7 +328,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo case mapActions.SETEXTENT: { let a = action as mapActions.SetExtent; return tassign(state, { extent: a.extent }); - } + } case mapActions.ADDLAYER: { let a = action as mapActions.AddLayer; let itemLayers = state.overlayLayers.slice(0); @@ -355,6 +355,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo newLayers.splice(i, 1); return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer }); } + case mapActions.CLEARLAYERS: { + return tassign(state, {overlayLayers: [], selectedOverlayLayer: null}); + } case mapActions.SETVISIBILITY: { let a = action as mapActions.SetVisibility; let newLayers = state.overlayLayers.slice(0); @@ -448,7 +451,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo let a = action as mapActions.SelectOverlayLayer; return tassign(state, { selectedOverlayLayer: a.itemLayer }); } - + case mapActions.CLEAR: { let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null }); return tassign(state, { @@ -480,7 +483,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo case mapActions.SETREPLACEURL: { let a= action as mapActions.SetReplaceUrl; return tassign(state,{replaceUrl:a.replaceUrl}); - } + } default: { return state; }