Refactor style cache

This commit is contained in:
Willem Dantuma
2020-02-12 20:38:14 +01:00
parent b83aca7969
commit 6379b64351
9 changed files with 258 additions and 224 deletions

View File

@@ -4,6 +4,7 @@ import { IItemLayer,ItemLayer} from '../models/item.layer';
import { IMapState} from '../models/map.state';
import { IQueryState} from '../models/query.state';
import { IPeriodState} from '../models/period.state';
import { IStyleCache} from '../models/style.cache';
import * as mapActions from '../actions/map.actions';
import {commonActions} from '@farmmaps/common';
import { createSelector, createFeatureSelector } from '@ngrx/store';
@@ -51,7 +52,8 @@ export interface State {
selectedItemLayer: IItemLayer,
projection: string,
selectedBaseLayer: IItemLayer,
selectedOverlayLayer: IItemLayer
selectedOverlayLayer: IItemLayer,
styleCache:IStyleCache
}
export const initialState: State = {
@@ -84,7 +86,8 @@ export const initialState: State = {
projection: "EPSG:3857",
selectedBaseLayer: null,
selectedOverlayLayer: null,
selectedItemLayer: null
selectedItemLayer: null,
styleCache: {}
}
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
@@ -310,6 +313,12 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
return tassign(state, {});
}
}
case mapActions.SETSTYLE:{
let a = action as mapActions.SetStyle;
let styles = state.styleCache;
styles[a.itemType] = a.style;
return tassign(state,{styleCache:styles});
}
default: {
return state;
}