Compare commits
No commits in common. "4bbc22cbde77b7df061797ebf54cadfcb174b675" and "af12682341a249cd5ecfb7c12ff7d942370d3cf0" have entirely different histories.
4bbc22cbde
...
af12682341
@ -128,21 +128,29 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
this.store.dispatch(new mapActions.Init());
|
this.store.dispatch(new mapActions.Init());
|
||||||
this.selectedFeatures$.next({x:0,y:0,features:[]});
|
this.selectedFeatures$.next({x:0,y:0,features:[]});
|
||||||
this.selectedFeatures$.next(null);
|
this.selectedFeatures$.next(null);
|
||||||
this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{
|
this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe((state) => {
|
||||||
if(setStateCount>0) {
|
let queryState = state[0][0];
|
||||||
this.replaceUrl(mapState,queryState,false);
|
let mapState = state[0][1];
|
||||||
}
|
let urlparts=[];
|
||||||
});
|
|
||||||
this.mapState$.pipe(withLatestFrom(this.queryState$),withLatestFrom(this.setStateCount$)).subscribe(([[mapState,queryState],setStateCount]) =>{
|
// TODO: fix this properly move the action to a separte column in itemtypes
|
||||||
if(setStateCount>0) {
|
if(queryState.itemType && queryState.itemCode) {
|
||||||
this.replaceUrl(mapState,queryState,true);
|
let itemType = this.itemTypeService.itemTypes[queryState.itemType];
|
||||||
}
|
if (itemType.viewer == "edit_in_editor" && itemType.editor) {
|
||||||
});
|
urlparts.push('/editor');
|
||||||
this.queryState$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{
|
urlparts.push(itemType.editor);
|
||||||
if(setStateCount>0) {
|
urlparts.push('item');
|
||||||
this.replaceUrl(mapState,queryState,true);
|
urlparts.push(queryState.itemCode);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
if(state[1]>0) {
|
||||||
|
if(urlparts.length>0) {
|
||||||
|
this.router.navigate(urlparts);
|
||||||
|
} else {
|
||||||
|
this.replaceUrl(mapState, queryState,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initCustomStyles() {
|
initCustomStyles() {
|
||||||
@ -199,10 +207,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.zone.run(()=> {
|
this.zone.run(()=> {
|
||||||
if ( queryStateChanged && mapStateChanged) {
|
if ( queryStateChanged && mapStateChanged) {
|
||||||
|
console.debug("Both states");
|
||||||
this.store.dispatch(new mapActions.SetState(newMapState,newQueryState));
|
this.store.dispatch(new mapActions.SetState(newMapState,newQueryState));
|
||||||
} else if(queryStateChanged) {
|
} else if(queryStateChanged) {
|
||||||
|
console.debug("Query state");
|
||||||
this.store.dispatch(new mapActions.SetQueryState(newQueryState));
|
this.store.dispatch(new mapActions.SetQueryState(newQueryState));
|
||||||
} else if (mapStateChanged) {
|
} else if (mapStateChanged) {
|
||||||
|
console.debug("Map state");
|
||||||
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -211,6 +222,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.map.instance.updateSize();
|
this.map.instance.updateSize();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
console.debug("Afterviewinit");
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearchCollapse(event) {
|
handleSearchCollapse(event) {
|
||||||
@ -242,6 +254,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) {
|
replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) {
|
||||||
|
console.debug(`Replace url : Baselayer(${mapState.baseLayerCode}) Querystate(${this.serializeService.serialize(queryState)})`);
|
||||||
let parts =["."];
|
let parts =["."];
|
||||||
parts.push(mapState.xCenter.toFixed(5));
|
parts.push(mapState.xCenter.toFixed(5));
|
||||||
parts.push(mapState.yCenter.toFixed(5));
|
parts.push(mapState.yCenter.toFixed(5));
|
||||||
@ -265,10 +278,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
let mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null };
|
let mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null };
|
||||||
let state = { mapState: mapState, extent: extent };
|
let state = { mapState: mapState, extent: extent };
|
||||||
let source = from([state]);
|
let source = from([state]);
|
||||||
source.pipe(withLatestFrom(this.selectedBaseLayer$)).subscribe(([state, baselayer]) => {
|
source.pipe(withLatestFrom(this.selectedBaseLayer$), withLatestFrom(this.queryState$)).subscribe(([[state, baselayer], queryState]) => {
|
||||||
if (mapState && baselayer) {
|
if (mapState && baselayer && queryState) {
|
||||||
let newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code });
|
let newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code });
|
||||||
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
this.replaceUrl(newMapState, tassign(queryState, { bbox: queryState.bboxFilter ? state.extent : queryState.bbox }));
|
||||||
this.store.dispatch(new mapActions.SetViewExtent(state.extent));
|
this.store.dispatch(new mapActions.SetViewExtent(state.extent));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,10 +26,6 @@ import {FeatureIconService} from '../services/feature-icon.service';
|
|||||||
|
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
|
|
||||||
import { ItemTypeService } from '@farmmaps/common';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MapEffects {
|
export class MapEffects {
|
||||||
@ -256,22 +252,7 @@ export class MapEffects {
|
|||||||
switchMap((action: mapActions.SetQueryState) => {
|
switchMap((action: mapActions.SetQueryState) => {
|
||||||
var newAction:Action;
|
var newAction:Action;
|
||||||
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
||||||
let urlparts=[];
|
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
||||||
if(action.queryState.itemType && action.queryState.itemType!= "") {
|
|
||||||
let itemType = this.itemTypeService$.itemTypes[action.queryState.itemType];
|
|
||||||
if (itemType.viewer == "edit_in_editor" && itemType.editor) {
|
|
||||||
urlparts.push('/editor');
|
|
||||||
urlparts.push(itemType.editor);
|
|
||||||
urlparts.push('item');
|
|
||||||
urlparts.push(action.queryState.itemCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(urlparts.length==0 ) {
|
|
||||||
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
|
||||||
} else {
|
|
||||||
this.router$.navigate(urlparts);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
newAction= new mapActions.StartSearch(action.queryState);
|
newAction= new mapActions.StartSearch(action.queryState);
|
||||||
}
|
}
|
||||||
@ -291,7 +272,7 @@ export class MapEffects {
|
|||||||
return of(newAction);
|
return of(newAction);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService,private router$:Router) {
|
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService) {
|
||||||
this._geojsonFormat = new GeoJSON();
|
this._geojsonFormat = new GeoJSON();
|
||||||
this._wktFormat = new WKT();
|
this._wktFormat = new WKT();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user