This commit is contained in:
parent
bc17f80050
commit
dad8e061ea
@ -166,13 +166,9 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
||||
|
||||
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];
|
||||
let lastQueryState:IQueryState = state[0][1];
|
||||
let lastMapState:IMapState = state[1];
|
||||
var newMapState: IMapState = null;
|
||||
var newQueryState: IQueryState = null;
|
||||
this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.setStateCount$),withLatestFrom(this.queryState$),withLatestFrom(this.mapState$)).subscribe( ([[[params,setStateCount],lastQueryState],lastMapState]) => {
|
||||
var newMapState: IMapState = lastMapState;
|
||||
var newQueryState: IQueryState = lastQueryState;
|
||||
var mapStateChanged = false;
|
||||
var queryStateChanged = false;
|
||||
if (params.has("xCenter") && params.has("yCenter")) {
|
||||
@ -182,7 +178,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)) && setStateCount == 0 ;
|
||||
mapStateChanged = (JSON.stringify(lastMapState) != JSON.stringify(newMapState));
|
||||
window.localStorage.setItem("FarmMapsCommonMap_mapState",JSON.stringify(newMapState));
|
||||
}
|
||||
if (params.has("queryState")) {
|
||||
@ -192,13 +188,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
||||
newQueryState = this.serializeService.deserialize(queryState);
|
||||
queryState = this.serializeService.serialize(newQueryState);
|
||||
}
|
||||
queryStateChanged = this.serializeService.serialize(lastQueryState) != queryState || setStateCount==0;
|
||||
queryStateChanged = this.serializeService.serialize(lastQueryState) != queryState;
|
||||
}
|
||||
let t =0;
|
||||
if(setStateCount==0) t=600;
|
||||
setTimeout(() => {
|
||||
this.zone.run(()=> {
|
||||
if ( queryStateChanged && mapStateChanged) {
|
||||
if ( (queryStateChanged && mapStateChanged) || setStateCount ==0) {
|
||||
this.store.dispatch(new mapActions.SetState(newMapState,newQueryState));
|
||||
} else if(queryStateChanged) {
|
||||
this.store.dispatch(new mapActions.SetQueryState(newQueryState));
|
||||
@ -265,8 +261,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
||||
let mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null };
|
||||
let state = { mapState: mapState, extent: extent };
|
||||
let source = from([state]);
|
||||
source.pipe(withLatestFrom(this.selectedBaseLayer$)).subscribe(([state, baselayer]) => {
|
||||
if (mapState && baselayer) {
|
||||
source.pipe(withLatestFrom(this.selectedBaseLayer$),withLatestFrom(this.setStateCount$)).subscribe(([[state, baselayer],setStateCount]) => {
|
||||
if (mapState && baselayer && setStateCount > 0) { // do not react on first move
|
||||
let newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code });
|
||||
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
||||
this.store.dispatch(new mapActions.SetViewExtent(state.extent));
|
||||
|
@ -316,8 +316,14 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
let itemLayers = state.overlayLayers.slice(0);
|
||||
let itemLayer = new ItemLayer(a.item);
|
||||
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
||||
let existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex);
|
||||
if(existing.length==0) {
|
||||
itemLayers.push(itemLayer);
|
||||
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
case mapActions.REMOVELAYER: {
|
||||
let a = action as mapActions.RemoveLayer;
|
||||
|
Loading…
Reference in New Issue
Block a user