diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts index 33b9a64..b6be6ed 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -15,7 +15,6 @@ export const SETPARENT = '[Map] SetParent'; export const STARTSEARCH = '[Map] StartSearch'; export const STARTSEARCHSUCCESS = '[Map] StartSearchSuccess'; export const SELECTFEATURE = '[Map] SelectFeature'; -export const CLICKFEATURE = '[Map] ClickFeature'; export const SELECTITEM = '[Map] SelectItem'; export const SELECTITEMSUCCESS = '[Map] SelectItemSuccess'; export const SELECTTEMPORALITEMSSUCCESS = '[Map] SelectTemporalItemsSuccess'; @@ -42,6 +41,12 @@ export const ZOOMTOEXTENT = '[Map] ZoomToExtent'; export const DOQUERY = '[Map] DoQuery'; export const SETSTYLE = '[Map] SetStyle'; export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher'; +export const CLEAR = '[Map] Clear'; + +export class Clear implements Action { + readonly type = CLEAR; + constructor() {} +} export class SetState implements Action { readonly type = SETSTATE; @@ -91,12 +96,6 @@ export class SelectFeature implements Action { constructor(public feature:Feature) { } } -export class ClickFeature implements Action { - readonly type = CLICKFEATURE; - - constructor(public feature:Feature) { } -} - export class SelectItem implements Action { readonly type = SELECTITEM; @@ -254,11 +253,11 @@ export class ShowLayerSwitcher implements Action { export type Actions = SetMapState | Init + | Clear | SetParent | StartSearch | StartSearchSuccess | SelectFeature - | ClickFeature | SelectItem | SelectItemSuccess | SelectTemporalItemsSuccess diff --git a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts b/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts index f25cd1c..83d4990 100644 --- a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts +++ b/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts @@ -32,7 +32,7 @@ export class ZoomToExtentComponent implements OnChanges { left = 23 * rem; } options.padding = [top, right, bottom, left]; - if (this.animate) options["duration"] = 2000; + if (this.animate) options["duration"] = 1000; this.view.instance.fit(this.extent, options); } } diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts index 3c870e7..e312a99 100644 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts @@ -49,9 +49,9 @@ export class FeatureListContainerComponent { viewContainerRef.clear(); this.componentRef = viewContainerRef.createComponent(componentFactory); - (this.componentRef.instance).features = this.features; - (this.componentRef.instance).queryState = this.queryState; - (this.componentRef.instance).selectedFeature = this.selectedFeature; + (this.componentRef.instance).features = null; + (this.componentRef.instance).queryState = queryState; + (this.componentRef.instance).selectedFeature = null; } ngOnInit() { @@ -61,10 +61,11 @@ export class FeatureListContainerComponent { } ngOnChanges(changes: SimpleChanges) { + if ((changes["queryState"] && changes["queryState"].currentValue)) { + this.loadComponent(changes["queryState"].currentValue); + } if ((changes["features"] && changes["features"].currentValue)) { - if (this.queryState) { - this.loadComponent(this.queryState); - } + (this.componentRef.instance).features = changes["features"].currentValue; } if(changes["selectedFeature"]) { (this.componentRef.instance).selectedFeature = changes["selectedFeature"].currentValue; diff --git a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html b/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html index b2262c2..1990c9c 100644 --- a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html +++ b/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html @@ -1,11 +1,11 @@ -
-
-
- -

Farm

-

{{schemeItem.name}}

-
-
+
+
+ +

Farm

+

{{schemeItem.name}}

+
+
+
diff --git a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html index 6cb9b5a..d46dd63 100644 --- a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html +++ b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html @@ -1,13 +1,13 @@ -
-
-
- +
+
+

 Farms

+
-
+
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 63df621..6099035 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, Inject, ViewChild, AfterViewInit,ChangeDetectorRef,NgZone } from '@angular/core'; import { Location } from '@angular/common'; -import { Observable, Subject, Subscription,combineLatest, from } from 'rxjs'; -import { debounce, withLatestFrom, first, combineAll } from 'rxjs/operators'; +import { Observable, Subject, Subscription,combineLatest, from,interval } from 'rxjs'; +import { debounce, withLatestFrom, first, combineAll,throttle } from 'rxjs/operators'; import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router'; import { Store } from '@ngrx/store'; //import { proj,Map } from 'openlayers'; @@ -63,7 +63,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public panelVisible$: Observable = this.store.select(mapReducers.selectGetPanelVisible); public panelCollapsed$: Observable = this.store.select(mapReducers.selectGetPanelCollapsed); public selectedFeature$: Observable = this.store.select(mapReducers.selectGetSelectedFeature); - public clickedFeature: Observable = this.store.select(mapReducers.selectGetClickedFeature); + public clickedFeature: Subject = new Subject(); public selectedItem$: Observable = this.store.select(mapReducers.selectGetSelectedItem); public queryState$: Observable = this.store.select(mapReducers.selectGetQueryState); public period$: Observable = this.store.select(mapReducers.selectGetPeriod); @@ -115,7 +115,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } handleFeatureClick(feature: Feature) { - this.store.dispatch(new mapActions.ClickFeature(feature)); + this.clickedFeature.next(feature); } handleFeatureHover(feature: Feature) { @@ -127,7 +127,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } ngOnInit() { - this.store.dispatch(new mapActions.Init()); + this.store.dispatch(new mapActions.Clear()); this.selectedFeatures$.next({x:0,y:0,features:[]}); this.selectedFeatures$.next(null); this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{ @@ -191,9 +191,9 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { 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 hasUrlmapState = params.has("xCenter") && params.has("yCenter"); var queryStateChanged = false; - if (params.has("xCenter") && params.has("yCenter")) { + if (hasUrlmapState) { let xCenter = parseFloat(params.get("xCenter")); let yCenter = parseFloat(params.get("yCenter")); let zoom = parseFloat(params.get("zoom")); diff --git a/projects/common-map/src/fm-map/reducers/map.reducer.ts b/projects/common-map/src/fm-map/reducers/map.reducer.ts index 169de10..f87e03f 100644 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ b/projects/common-map/src/fm-map/reducers/map.reducer.ts @@ -43,7 +43,6 @@ export interface State { panelVisible: boolean, panelCollapsed: boolean, selectedFeature: Feature, - clickedFeature: Feature, selectedItem:IItem, clearEnabled: boolean, searchCollapsed: boolean, @@ -80,7 +79,6 @@ export const initialState: State = { panelVisible: false, panelCollapsed: false, selectedFeature: null, - clickedFeature: null, selectedItem: null, clearEnabled: false, searchCollapsed: true, @@ -139,10 +137,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo } } } - return tassign(state, { - panelVisible: true, - clearEnabled: true, - searchMinified: true, + return tassign(state, { features: a.features, extent:extent }); @@ -150,16 +145,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo case mapActions.SELECTFEATURE: { let a = action as mapActions.SelectFeature; return tassign(state, { - selectedFeature: state.selectedItem?state.selectedFeature: a.feature, - clickedFeature:null + selectedFeature: state.selectedItem?state.selectedFeature: a.feature }); - } - case mapActions.CLICKFEATURE: { - let a = action as mapActions.ClickFeature; - return tassign(state, { - clickedFeature: a.feature - }); - } + } case mapActions.SELECTITEM: { return tassign(state, { selectedItem: null, @@ -270,9 +258,13 @@ export function reducer(state = initialState, action: mapActions.Actions | commo let a = action as mapActions.StartSearch; return tassign(state, { selectedItem: null, + features:[], selectedItemLayer:null, queryState: tassign(a.queryState), searchCollapsed: false, + panelVisible: true, + clearEnabled: true, + searchMinified: true, }); } case mapActions.DOQUERY: { @@ -288,7 +280,6 @@ export function reducer(state = initialState, action: mapActions.Actions | commo return tassign(state, { panelVisible: true, selectedFeature: a.feature, - clickedFeature:null, extent: a.feature.getGeometry().getExtent(), searchCollapsed: false, clearEnabled:true, @@ -444,7 +435,6 @@ export function reducer(state = initialState, action: mapActions.Actions | commo selectedItem: null, selectedItemLayer: null, selectedFeature: null, - clickedFeature:null, queryState: newQueryState, clearEnabled: false, searchCollapsed: true, @@ -467,8 +457,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo let a = action as mapActions.ShowLayerSwitcher; return tassign(state,{showLayerSwitcher:a.show}); } - case mapActions.INIT:{ - return tassign(state,{setStateCount:0}); + case mapActions.CLEAR:{ + return tassign(state,{setStateCount:0,features:[],selectedFeature:null,selectedItem:null}); } default: { return state; @@ -482,7 +472,6 @@ export const getFeatures = (state: State) => state.features; export const getPanelVisible = (state: State) => state.panelVisible; export const getPanelCollapsed = (state: State) => state.panelCollapsed; export const getSelectedFeature = (state: State) => state.selectedFeature; -export const getClickedFeature = (state: State) => state.clickedFeature; export const getSelectedItem = (state: State) => state.selectedItem; export const getQueryState = (state: State) => state.queryState; export const getClearEnabled = (state: State) => state.clearEnabled; @@ -508,7 +497,6 @@ export const selectGetFeatures = createSelector(selectMapState, getFeatures); export const selectGetPanelVisible = createSelector(selectMapState, getPanelVisible); export const selectGetPanelCollapsed = createSelector(selectMapState, getPanelCollapsed); export const selectGetSelectedFeature = createSelector(selectMapState, getSelectedFeature); -export const selectGetClickedFeature = createSelector(selectMapState, getClickedFeature); export const selectGetSelectedItem = createSelector(selectMapState, getSelectedItem); export const selectGetQueryState = createSelector(selectMapState, getQueryState); export const selectGetClearEnabled = createSelector(selectMapState, getClearEnabled);