Fix zoom to extent
This commit is contained in:
@@ -4,11 +4,11 @@ import { Store, Action } from '@ngrx/store';
|
||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
||||
|
||||
import { Observable , of } from 'rxjs';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap,delay } from 'rxjs/operators';
|
||||
|
||||
import {GeoJSON,WKT} from 'ol/format';
|
||||
import {Feature} from 'ol';
|
||||
import { getCenter } from 'ol/extent';
|
||||
import { getCenter,createEmpty,extend } from 'ol/extent';
|
||||
import {Point} from 'ol/geom'
|
||||
|
||||
|
||||
@@ -137,10 +137,29 @@ export class MapEffects {
|
||||
|
||||
|
||||
@Effect()
|
||||
startSearchSucces$: Observable<Action> = this.actions$.pipe(
|
||||
zoomToExtent$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||
delay(500),
|
||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||
let actions =[];
|
||||
actions.push(new commonActions.SetMenuVisible(false));
|
||||
let extent = createEmpty();
|
||||
if (!action.query.bboxFilter) {
|
||||
if (extent) {
|
||||
for (let f of action.features) {
|
||||
extend(extent, (f as Feature).getGeometry().getExtent());
|
||||
}
|
||||
}
|
||||
actions.push(new mapActions.SetExtent(extent));
|
||||
}
|
||||
return actions;
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
hideMenu$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||
return [new commonActions.SetMenuVisible(false)];
|
||||
return of(new commonActions.SetMenuVisible(false));
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
|
Reference in New Issue
Block a user