Add layer values
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<div #layerValues class="layer-values">
|
||||
<div class="cross" *ngIf="enabled$ | async">
|
||||
<div class="pointer"></div>
|
||||
<div class="values-container border border-dark rounded p-2" *ngIf="(layerValues$ | async ) as layers">
|
||||
<div class="lonlat pb-2 "><span class="font-weight-bold">{{lonlat$}}</span><i class="ml-2 fal fa-copy" (click)="copyToClipboard()"></i> </div>
|
||||
<ul class="value-list p-0 mb-0" *ngIf="layers.length>0 ;else no_data">
|
||||
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||
<div>{{layerValue.layerName}}</div>
|
||||
<div>{{layerValue.date|date}}</div>
|
||||
<div><span>{{layerValue.quantity}}</span> <span>{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
<ng-template #no_data>
|
||||
<div i18n class="border-top pt-1 pb-1">No data at location</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>>
|
@@ -0,0 +1,37 @@
|
||||
.layer-values {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 30%;
|
||||
}
|
||||
|
||||
.cross {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
left: -0.5em;
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
.values-container {
|
||||
position: relative;
|
||||
background-color: white;
|
||||
left: calc( 1em - 1px);
|
||||
top: -1.3em;
|
||||
min-width: 15em;
|
||||
}
|
||||
|
||||
.value-list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
position: relative;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
left: 0.5em;
|
||||
border-top: 0.5em solid transparent;
|
||||
border-bottom: 0.5em solid transparent;
|
||||
border-right: 0.5em solid black;
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LayerValuesComponent } from './layer-values.component';
|
||||
|
||||
describe('LayerValuesComponent', () => {
|
||||
let component: LayerValuesComponent;
|
||||
let fixture: ComponentFixture<LayerValuesComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ LayerValuesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LayerValuesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@@ -0,0 +1,59 @@
|
||||
import { Component, OnInit,Input,ViewChild,ElementRef,AfterViewInit } from '@angular/core';
|
||||
import {IItemLayer} from '../../../models/item.layer';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as mapReducers from '../../../reducers/map.reducer';
|
||||
import * as mapActions from '../../../actions/map.actions';
|
||||
import { MapComponent } from 'ngx-openlayers';
|
||||
import { ILayervalue } from '../../../models/layer.value';
|
||||
import { Observable,interval } from 'rxjs';
|
||||
import { debounce } from 'rxjs/operators';
|
||||
import { toLonLat } from 'ol/proj';
|
||||
import { toStringHDMS } from 'ol/coordinate';
|
||||
import { ClipboardService } from 'ngx-clipboard'
|
||||
import {GeoJSON,WKT} from 'ol/format';
|
||||
import { Point } from 'ol/geom';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-map-layer-values',
|
||||
templateUrl: './layer-values.component.html',
|
||||
styleUrls: ['./layer-values.component.scss']
|
||||
})
|
||||
export class LayerValuesComponent implements OnInit,AfterViewInit {
|
||||
|
||||
@ViewChild('layerValues') containerRef:ElementRef;
|
||||
offsetX$:number =0;
|
||||
offsetY$:number =0;
|
||||
lonlat$: string="";
|
||||
wkt$= "";
|
||||
layerValues$:Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||
enabled$:Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||
wktFormat$:WKT;
|
||||
|
||||
constructor( private store: Store<mapReducers.State>,private map: MapComponent,private clipboardService$:ClipboardService) {
|
||||
this.wktFormat$=new WKT();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit():void {
|
||||
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
||||
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
||||
this.map.instance.on('moveend', () => {
|
||||
this.updateValuesLocation();
|
||||
});
|
||||
}
|
||||
|
||||
updateValuesLocation() {
|
||||
var xy = this.map.instance.getCoordinateFromPixel([this.offsetX$,this.offsetY$])
|
||||
var lonlat = toLonLat(xy);
|
||||
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
||||
this.lonlat$ = toStringHDMS(lonlat);
|
||||
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0],xy[1]));
|
||||
}
|
||||
|
||||
copyToClipboard() {
|
||||
this.clipboardService$.copy(this.wkt$);
|
||||
}
|
||||
}
|
@@ -22,7 +22,7 @@
|
||||
selectedFeature:selectedFeature$|async,
|
||||
fullscreen:fullscreen$|async
|
||||
} as state">
|
||||
<aol-map #map (moveEnd)="handleOnMoveEnd($event)" (click)="handleOnMouseDown($event)" [ngClass]="{'panel-visible':state.panelVisible,'fullscreen':state.fullscreen}" class="map">
|
||||
<aol-map #map (moveEnd)="handleOnMoveEnd($event)" (click)="handleOnMouseDown($event)" (dblClick)="handleShowLayerValues($event)" [ngClass]="{'panel-visible':state.panelVisible,'fullscreen':state.fullscreen}" class="map">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
@@ -40,6 +40,7 @@
|
||||
</aol-layer-vector>
|
||||
<router-outlet name="map-layers"></router-outlet>
|
||||
<fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="devicesService.IsMobile()" [showTolerance]="devicesService.IsMobile()" [heading]="state.compassHeading"></fm-map-gps-location>
|
||||
<fm-map-layer-values></fm-map-layer-values>
|
||||
<div class="control-container" >
|
||||
<router-outlet name="map-controls"></router-outlet>
|
||||
<fm-map-layer-switcher></fm-map-layer-switcher>
|
||||
|
@@ -383,6 +383,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
||||
});
|
||||
}
|
||||
|
||||
handleShowLayerValues(event: MouseEvent) {
|
||||
event.stopPropagation();
|
||||
this.zone.run(() =>{
|
||||
this.store.dispatch(new mapActions.ToggleLayerValuesEnabled());
|
||||
});
|
||||
}
|
||||
|
||||
handleOnDownload(event) {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user