More refactoring, add thematic maps button

This commit is contained in:
Willem Dantuma
2020-04-22 08:11:50 +02:00
parent ef81b04f4e
commit 69751540d3
4 changed files with 34 additions and 16 deletions

View File

@@ -113,9 +113,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
} else {
newQueryState= queryState;
}
if(urlparts.length==0 ) {
if(urlparts.length==0 ) {
newQueryState.itemCode = queryState.itemCode;
this.replaceUrl(mapState,newQueryState,false);
this.store.dispatch(new mapActions.SetQueryState(newQueryState,false));
//this.replaceUrl(mapState,newQueryState,false);
} else {
this.router.navigate(urlparts);
}
@@ -257,17 +258,17 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(newMapState));
} else if(queryStateChanged) {
return of(new mapActions.SetQueryState(newQueryState));
} return of(null)
} return of(new mapActions.SetReplaceUrl(true));
})).subscribe((action) => {
if(action) {
console.debug("Url to state");
this.store.dispatch(action);
}
if(action) {
console.debug("Url to state");
this.store.dispatch(action);
}
});
// state to url
this.stateSub = this.state$.pipe(withLatestFrom(this.route.paramMap),switchMap(([state,params]) => {
this.stateSub = this.state$.pipe(switchMap((state) => {
let newUrl = this.serializeMapState(state.mapState) + "_" + this.serializeService.serialize(state.queryState);
if(this.lastUrl!=newUrl && state.setStateCount>0) {
this.lastUrl=newUrl;
@@ -279,7 +280,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
})).subscribe((newUrlState) =>{
if(newUrlState) {
console.debug(`State to url ${newUrlState.setStateCount}`);
this.replaceUrl(newUrlState.mapState,newUrlState.queryState,true);
this.replaceUrl(newUrlState.mapState,newUrlState.queryState,newUrlState.replaceUrl);
}
});