add clearlayers action
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Mark van der Wal 2020-12-16 23:01:59 +01:00
parent a0816afaea
commit a782d8ebe9
2 changed files with 14 additions and 3 deletions

View File

@ -33,6 +33,7 @@ export const SETVISIBILITY = '[Map] SetVisibility';
export const SETOPACITY = '[Map] SetOpacity'; export const SETOPACITY = '[Map] SetOpacity';
export const SETLAYERINDEX = '[Map] SetLayerIndex'; export const SETLAYERINDEX = '[Map] SetLayerIndex';
export const REMOVELAYER = '[Map] RemoveLayer'; export const REMOVELAYER = '[Map] RemoveLayer';
export const CLEARLAYERS = '[Map] ClearLayers';
export const LOADBASELAYERS = '[Map] LoadLayers'; export const LOADBASELAYERS = '[Map] LoadLayers';
export const LOADBASELAYERSSUCCESS = '[Map] LoadLayersSuccess'; export const LOADBASELAYERSSUCCESS = '[Map] LoadLayersSuccess';
export const SELECTBASELAYER = '[Map] SelectBaseLayers'; export const SELECTBASELAYER = '[Map] SelectBaseLayers';
@ -212,6 +213,12 @@ export class RemoveLayer implements Action {
constructor(public itemLayer: IItemLayer) { } constructor(public itemLayer: IItemLayer) { }
} }
export class ClearLayers implements Action {
readonly type = CLEARLAYERS;
constructor() { }
}
export class LoadBaseLayers implements Action { export class LoadBaseLayers implements Action {
readonly type = LOADBASELAYERS; readonly type = LOADBASELAYERS;
@ -292,6 +299,7 @@ export type Actions = SetMapState
| SetTimeSpan | SetTimeSpan
| AddLayer | AddLayer
| RemoveLayer | RemoveLayer
| ClearLayers
| SetVisibility | SetVisibility
| SetOpacity | SetOpacity
| SetLayerIndex | SetLayerIndex

View File

@ -328,7 +328,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
case mapActions.SETEXTENT: { case mapActions.SETEXTENT: {
let a = action as mapActions.SetExtent; let a = action as mapActions.SetExtent;
return tassign(state, { extent: a.extent }); return tassign(state, { extent: a.extent });
} }
case mapActions.ADDLAYER: { case mapActions.ADDLAYER: {
let a = action as mapActions.AddLayer; let a = action as mapActions.AddLayer;
let itemLayers = state.overlayLayers.slice(0); let itemLayers = state.overlayLayers.slice(0);
@ -355,6 +355,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
newLayers.splice(i, 1); newLayers.splice(i, 1);
return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer }); return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer });
} }
case mapActions.CLEARLAYERS: {
return tassign(state, {overlayLayers: [], selectedOverlayLayer: null});
}
case mapActions.SETVISIBILITY: { case mapActions.SETVISIBILITY: {
let a = action as mapActions.SetVisibility; let a = action as mapActions.SetVisibility;
let newLayers = state.overlayLayers.slice(0); 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; let a = action as mapActions.SelectOverlayLayer;
return tassign(state, { selectedOverlayLayer: a.itemLayer }); return tassign(state, { selectedOverlayLayer: a.itemLayer });
} }
case mapActions.CLEAR: { case mapActions.CLEAR: {
let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null }); let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
return tassign(state, { return tassign(state, {
@ -480,7 +483,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
case mapActions.SETREPLACEURL: { case mapActions.SETREPLACEURL: {
let a= action as mapActions.SetReplaceUrl; let a= action as mapActions.SetReplaceUrl;
return tassign(state,{replaceUrl:a.replaceUrl}); return tassign(state,{replaceUrl:a.replaceUrl});
} }
default: { default: {
return state; return state;
} }