Fix several issues, attemt to fix zooming issue
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma
2020-02-21 00:11:18 +01:00
parent abfef73cd1
commit 3a38c24360
5 changed files with 68 additions and 58 deletions

View File

@@ -91,7 +91,6 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
private geolocationService: GeolocationService,
private zone: NgZone,
private deviceorientationService:DeviceOrientationService) {
this.initCustomStyles();
}
@HostListener('document:keyup', ['$event'])
@@ -126,12 +125,12 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
}
ngOnInit() {
this.store.dispatch(new mapActions.Init());
this.store.dispatch(new mapActions.Init());
this.selectedFeatures$.next({x:0,y:0,features:[]});
this.selectedFeatures$.next(null);
this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe((state) => {
if(state[1]>0) this.replaceUrl(state[0][1], state[0][0],false);
});
});
}
initCustomStyles() {
@@ -153,7 +152,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
})));
}
ngAfterViewInit() {
ngAfterViewInit() {
this.initCustomStyles();
this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.setStateCount$),withLatestFrom(this.queryState$),withLatestFrom(this.mapState$)).subscribe( (state) => {
let params: ParamMap = state[0][0][0];
let setStateCount:number = state[0][0][1];
@@ -170,7 +170,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
let rotation = parseFloat(params.get("rotation"));
let baseLayer = params.get("baseLayer")?params.get("baseLayer"):"";
newMapState = { xCenter: xCenter, yCenter: yCenter, zoom: zoom, rotation: rotation, baseLayerCode: baseLayer }
mapStateChanged = JSON.stringify(lastMapState) != JSON.stringify(newMapState);
mapStateChanged = (JSON.stringify(lastMapState) != JSON.stringify(newMapState)) && setStateCount == 0 ;
window.localStorage.setItem("FarmMapsCommonMap_mapState",JSON.stringify(newMapState));
}
if (params.has("queryState")) {
@@ -181,21 +181,26 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
queryState = this.serializeService.serialize(newQueryState);
}
queryStateChanged = this.serializeService.serialize(lastQueryState) != queryState;
}
this.zone.run(()=> {
if ( queryStateChanged) {
console.debug("Query state");
this.store.dispatch(new mapActions.SetQueryState(newQueryState));
} else if (mapStateChanged) {
console.debug("Map state");
this.store.dispatch(new mapActions.SetMapState(newMapState));
}
})
}
setTimeout(() => {
this.zone.run(()=> {
if ( queryStateChanged && mapStateChanged) {
console.debug("Both states");
this.store.dispatch(new mapActions.SetState(newMapState,newQueryState));
} else if(queryStateChanged) {
console.debug("Query state");
this.store.dispatch(new mapActions.SetQueryState(newQueryState));
} else if (mapStateChanged) {
console.debug("Map state");
this.store.dispatch(new mapActions.SetMapState(newMapState));
}
})
},0);
});
setTimeout(() => {
this.map.instance.updateSize();
}, 500);
console.debug("Afterviewinit");
}
handleSearchCollapse(event) {