diff --git a/projects/common-map/src/fm-map/common-map-routing.module.ts b/projects/common-map/src/fm-map/common-map-routing.module.ts index dc30dff..7bd5811 100644 --- a/projects/common-map/src/fm-map/common-map-routing.module.ts +++ b/projects/common-map/src/fm-map/common-map-routing.module.ts @@ -8,6 +8,10 @@ const routes = [ path: '', component: MapComponent }, + { + path: ':xCenter/:yCenter/:zoom/:rotation/:baseLayer', + component: MapComponent + }, { path: ':xCenter/:yCenter/:zoom/:rotation/:baseLayer/:queryState', component: MapComponent diff --git a/projects/common-map/src/fm-map/components/map/map.component.html b/projects/common-map/src/fm-map/components/map/map.component.html index c7a11f3..f9895dc 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.html +++ b/projects/common-map/src/fm-map/components/map/map.component.html @@ -19,9 +19,10 @@ period:period$|async, compassHeading:compassHeading$|async, styles:styles$|async, - selectedFeature:selectedFeature$|async + selectedFeature:selectedFeature$|async, + fullscreen:fullscreen$|async } as state"> - +
@@ -38,7 +39,7 @@ -
+
@@ -46,9 +47,11 @@
- - -
+
+ +
+ +
@@ -65,7 +68,10 @@
Cannot find tag {{state.queryState?.tags}}
-
+
+ + + diff --git a/projects/common-map/src/fm-map/components/map/map.component.scss b/projects/common-map/src/fm-map/components/map/map.component.scss index 79bf62d..41a86b4 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.scss +++ b/projects/common-map/src/fm-map/components/map/map.component.scss @@ -49,6 +49,10 @@ aol-map { position:absolute;width:100%;height:calc(100vh + 4rem);} .control-container { position: absolute; right: 1em; + bottom: 8.1em; +} + +.fullscreen .control-container { bottom: 5em; } 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 0368cf3..62b3f81 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,4 +1,4 @@ -import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit,NgZone } from '@angular/core'; +import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit,NgZone,ElementRef } from '@angular/core'; import { Location } from '@angular/common'; import { Observable, Subject, Subscription, from,of ,EMPTY } from 'rxjs'; import { withLatestFrom, switchMap,skip } from 'rxjs/operators'; @@ -79,10 +79,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public overlayLayersCollapsed: boolean = true; public extent$: Observable = this.store.select(mapReducers.selectGetExtent); public styles$:Observable = this.store.select(mapReducers.selectGetStyles); + public fullscreen$: Observable = this.store.select(commonReducers.selectGetFullScreen); private lastUrl = ""; private initialized: boolean = false; + public noContent: boolean = false; @ViewChild('map') map; + @ViewChild('contentDiv') contentDiv: ElementRef; constructor(private store: Store, private route: ActivatedRoute, @@ -162,7 +165,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { this.store.dispatch(new mapActions.DoQuery(queryState)); } - ngOnInit() { + ngOnInit() { this.initialized = false; console.debug("Init"); this.store.dispatch(new mapActions.Clear()); @@ -237,23 +240,27 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { ngAfterViewInit() { console.debug("View init"); + if(this.route.children.length == 0) { + this.noContent=true; + } + this.initCustomStyles(); // url to state let urlMapState = this.getMapStateFromUrl(this.route.snapshot.paramMap); let urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap); - if(urlQueryState && urlMapState) { + if(urlQueryState && urlMapState && this.noContent) { this.store.dispatch(new mapActions.SetState(urlMapState,urlQueryState)); window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(urlMapState)); - } else if(urlQueryState) { + } else if(urlQueryState && this.noContent) { this.store.dispatch(new mapActions.SetQueryState(urlQueryState)); } else { this.store.dispatch(new mapActions.SetReplaceUrl(true)); } this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.state$),switchMap(([params,state]) => { - if(this.initialized) { + if(this.initialized && this.noContent) { let urlQueryState = this.getQueryStateFromUrl(params); if( this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState)) { return of(new mapActions.SetState(state.mapState,urlQueryState)); @@ -318,24 +325,25 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { } replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) { - - let newMapState = this.serializeMapState(mapState); - let newQueryState = this.serializeService.serialize(queryState); - let currentMapState = this.serializeMapState(this.getMapStateFromUrl(this.route.snapshot.paramMap)); - let urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap); - let currentQueryState = urlQueryState==null?"":this.serializeService.serialize(urlQueryState); - if(mapState.baseLayerCode!="" && ((newMapState!= currentMapState) || (newQueryState!=currentQueryState))) { - let parts =["."]; - parts.push(mapState.xCenter.toFixed(5)); - parts.push(mapState.yCenter.toFixed(5)); - parts.push( mapState.zoom.toFixed(0)); - parts.push( mapState.rotation.toFixed(2)); - parts.push(mapState.baseLayerCode); - parts.push( this.serializeService.serialize(queryState)); - - console.debug("Replace url",parts); - this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent }); - } + if(this.noContent) { + let newMapState = this.serializeMapState(mapState); + let newQueryState = this.serializeService.serialize(queryState); + let currentMapState = this.serializeMapState(this.getMapStateFromUrl(this.route.snapshot.paramMap)); + let urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap); + let currentQueryState = urlQueryState==null?"":this.serializeService.serialize(urlQueryState); + if(mapState.baseLayerCode!="" && ((newMapState!= currentMapState) || (newQueryState!=currentQueryState))) { + let parts =["."]; + parts.push(mapState.xCenter.toFixed(5)); + parts.push(mapState.yCenter.toFixed(5)); + parts.push( mapState.zoom.toFixed(0)); + parts.push( mapState.rotation.toFixed(2)); + parts.push(mapState.baseLayerCode); + parts.push( this.serializeService.serialize(queryState)); + + console.debug("Replace url",parts); + this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent }); + } + } } handleOnMoveEnd(event) {