implement layer compare slider

This commit is contained in:
Willem Dantuma
2022-09-27 19:58:08 +02:00
parent 7b2dbc1777
commit ddb112b989
11 changed files with 192 additions and 31 deletions

View File

@@ -5,7 +5,7 @@ import { withLatestFrom, switchMap,skip } from 'rxjs/operators';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { Store } from '@ngrx/store';
import { DeviceService } from '@farmmaps/common';
//import { proj,Map } from 'openlayers';
import {getRenderPixel} from 'ol/render';
// Map
import * as mapReducers from '../../reducers/map.reducer';
@@ -76,6 +76,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
public clearEnabled$: Observable<boolean> = this.store.select(mapReducers.selectGetClearEnabled);
public searchCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchCollapsed);
public searchMinified$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchMinified);
public showDataLayerSlide$: Observable<boolean> = this.store.select(mapReducers.selectGetShowdataLayerSlide);
public menuVisible$: Observable<boolean>;
public query$: Observable<IQuery> = this.store.select(mapReducers.selectGetQuery);
public position$: Observable<GeolocationPosition> = this.geolocationService.getCurrentPosition();
@@ -90,6 +91,9 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
public noContent: boolean = false;
public overrideSelectedItemLayer: boolean = false;
public overrideOverlayLayers: boolean = false;
public dataLayerSlideValue:number = 50;
public dataLayerSlideEnabled = false;
private visibleAreaBottom = 0;
@ViewChild('map') map;
@ViewChild('contentDiv') contentDiv: ElementRef;
@@ -155,6 +159,25 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
}
}
handlePanelResize(resizeTop:number) {
if(resizeTop==100 || !this.devicesService.IsMobile() ) {
this.visibleAreaBottom=0;
} else {
this.visibleAreaBottom=100-resizeTop;
if(this.visibleAreaBottom>60) {
this.visibleAreaBottom=60;
}
}
}
bottom(panelVisible:boolean) {
if(panelVisible) {
return this.visibleAreaBottom + '%';
} else {
return "0%";
}
}
handleOpenModal(modalName: string) {
this.store.dispatch(new commonActions.OpenModal(modalName));
}
@@ -191,6 +214,31 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
}
}
handlePrerender(event:any) {
if(!this.dataLayerSlideEnabled) return;
const ctx = event.context;
const mapSize = this.map.instance.getSize();
const width = mapSize[0] * (this.dataLayerSlideValue / 100);
const tl = getRenderPixel(event, [width, 0]);
const tr = getRenderPixel(event, [mapSize[0], 0]);
const bl = getRenderPixel(event, [width, mapSize[1]]);
const br = getRenderPixel(event, mapSize);
ctx.save();
ctx.beginPath();
ctx.moveTo(tl[0], tl[1]);
ctx.lineTo(bl[0], bl[1]);
ctx.lineTo(br[0], br[1]);
ctx.lineTo(tr[0], tr[1]);
ctx.closePath();
ctx.clip();
}
handleSlideChange(event:any) {
this.dataLayerSlideValue = event.target.value;
this.map.instance.render();
}
ngOnInit() {
this.initialized = false;
console.debug("Init");
@@ -323,6 +371,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
}
});
this.initialized = true;
this.showDataLayerSlide$.subscribe((v) => {
this.dataLayerSlideEnabled=v;
this.map.instance.render();
});
}
handleSearchCollapse(event) {