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

This commit is contained in:
Willem Dantuma 2020-12-11 13:35:51 +01:00
parent 7266c98a10
commit 6746047fe2
3 changed files with 28 additions and 1 deletions

View File

@ -42,6 +42,7 @@ export const SETSTYLE = '[Map] SetStyle';
export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher'; export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher';
export const CLEAR = '[Map] Clear'; export const CLEAR = '[Map] Clear';
export const SETREPLACEURL = '[Map] SetReplaceUrl'; export const SETREPLACEURL = '[Map] SetReplaceUrl';
export const SETFEATURES = '[Map] SetFeatures'
export class Clear implements Action { export class Clear implements Action {
readonly type = CLEAR; readonly type = CLEAR;
@ -256,6 +257,12 @@ export class SetReplaceUrl implements Action {
constructor(public replaceUrl:boolean) {} constructor(public replaceUrl:boolean) {}
} }
export class SetFeatures implements Action {
readonly type = SETFEATURES;
constructor(public features: Array<Feature>) { }
}
export type Actions = SetMapState export type Actions = SetMapState
| Init | Init
| Clear | Clear
@ -291,5 +298,6 @@ export type Actions = SetMapState
| DoQuery | DoQuery
| SetStyle | SetStyle
| ShowLayerSwitcher | ShowLayerSwitcher
| SetReplaceUrl; | SetReplaceUrl
| SetFeatures;

View File

@ -150,6 +150,19 @@ export class MapEffects {
return actions; return actions;
})); }));
@Effect()
zoomToExtent2$: Observable<Action> = 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() @Effect()
hideMenu$: Observable<Action> = this.actions$.pipe( hideMenu$: Observable<Action> = this.actions$.pipe(
ofType(mapActions.STARTSEARCHSUCCESS), ofType(mapActions.STARTSEARCHSUCCESS),

View File

@ -138,6 +138,12 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
inSearch:false inSearch:false
}); });
} }
case mapActions.SETFEATURES: {
let a = action as mapActions.SetFeatures;
return tassign(state, {
features: a.features
});
}
case mapActions.SELECTFEATURE: { case mapActions.SELECTFEATURE: {
let a = action as mapActions.SelectFeature; let a = action as mapActions.SelectFeature;
return tassign(state, { return tassign(state, {