From dcc24aa1493671b3cd88f43dff2d8dff1c601e27 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Mon, 19 Apr 2021 08:43:20 +0200 Subject: [PATCH] Fix setExtent --- .../common-map/src/fm-map/effects/map.effects.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 01ca2bd..edf501e 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -154,14 +154,15 @@ export class MapEffects { @Effect() zoomToExtent2$: Observable = this.actions$.pipe( ofType(mapActions.SETFEATURES), - map((action: mapActions.SetFeatures) => { + switchMap((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); + if (extent) { + for (let f of action.features) { + extend(extent, (f as Feature).getGeometry().getExtent()); + } + if(action.features.length>0) return of(new mapActions.SetExtent(extent)); + } + return EMPTY; })); @Effect()