diff --git a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts index cf3917c..171a136 100644 --- a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts +++ b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts @@ -68,7 +68,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements } else { evaluatedStyle = this.stylesCache["selected"]; } - if(evaluatedStyle && evaluatedStyle.geometry_ == null) { + if(evaluatedStyle ) { evaluatedStyle.setGeometry((feature) => this.geometry(feature)); } return evaluatedStyle diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts index 10904b6..23c0c8f 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ b/projects/common-map/src/fm-map/components/map/map.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit,NgZone } from '@angular/core'; import { Location } from '@angular/common'; import { Observable, Subject, Subscription, from,of } from 'rxjs'; -import { withLatestFrom, switchMap } from 'rxjs/operators'; +import { withLatestFrom, switchMap,skip } from 'rxjs/operators'; import { Router, ActivatedRoute, ParamMap } from '@angular/router'; import { Store } from '@ngrx/store'; //import { proj,Map } from 'openlayers'; @@ -93,34 +93,32 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { private geolocationService: GeolocationService, private zone: NgZone, private deviceorientationService:DeviceOrientationService) { - this.querySub = this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{ + this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{ if(queryState) { let newQueryState = tassign(mapReducers.initialQueryState); - let initial = this.serializeService.serialize(newQueryState) == this.serializeService.serialize(queryState); - if(setStateCount>1 && !initial) { - console.debug(`Do Query ${setStateCount}`); - let urlparts=[]; - if (queryState.itemCode && queryState.itemCode != "") { - if(queryState.itemType && queryState.itemType!= "") { - let itemType = this.itemTypeService.itemTypes[queryState.itemType]; - if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) { - urlparts.push('/editor'); - urlparts.push(itemType.editor); - urlparts.push('item'); - urlparts.push(queryState.itemCode); - } - } - } else { - newQueryState= queryState; - } - if(urlparts.length==0 ) { - newQueryState.itemCode = queryState.itemCode; - this.store.dispatch(new mapActions.SetQueryState(newQueryState,false)); - //this.replaceUrl(mapState,newQueryState,false); - } else { - this.router.navigate(urlparts); - } + console.debug(`Do Query ${setStateCount}`); + let urlparts=[]; + if (queryState.itemCode && queryState.itemCode != "") { + if(queryState.itemType && queryState.itemType!= "") { + let itemType = this.itemTypeService.itemTypes[queryState.itemType]; + if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) { + urlparts.push('/editor'); + urlparts.push(itemType.editor); + urlparts.push('item'); + urlparts.push(queryState.itemCode); + } + } + } else { + newQueryState= queryState; } + if(urlparts.length==0 ) { + newQueryState.itemCode = queryState.itemCode; + this.zone.run(() => { + this.store.dispatch(new mapActions.SetQueryState(newQueryState,false)); + }) + } else { + this.router.navigate(urlparts); + } } }); } @@ -260,9 +258,11 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { return of(new mapActions.SetQueryState(newQueryState)); } return of(new mapActions.SetReplaceUrl(true)); })).subscribe((action) => { - if(action) { - console.debug("Url to state"); - this.store.dispatch(action); + if(action) { + this.zone.run(() => { + console.debug("Url to state"); + this.store.dispatch(action); + }); } }); 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 1c44ffe..1715dd1 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -220,21 +220,6 @@ export class MapEffects { switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode}))) )); - //@Effect() - //itemAdded$: Observable = this.actions$.pipe( - // ofType(commonActions.ITEMADDEDEVENT), - // withLatestFrom(this.store$.select(mapReducers.selectGetParentCode)), - // mergeMap(([action, parentCode]) => { - // let itemAddedAction = action as commonActions.ItemAddedEvent; - // if (parentCode && itemAddedAction.attributes["parentCode"] == parentCode) { - // return this.itemService$.getFeature(itemAddedAction.itemCode,"EPSG:3857").pipe( - // map((feature: Feature) => new mapActions.AddFeatureSuccess(this.toPointFeature(feature))), - // catchError(error => of(new commonActions.Fail(error)))) - // } else - // return [ - // ]; - // })); - @Effect() featureUpdate$: Observable = this.actions$.pipe( ofType(commonActions.DEVICEUPDATEEVENT),