|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Component, Input, OnChanges, OnDestroy, OnInit, AfterViewInit, SimpleChanges } from '@angular/core';
|
|
|
+import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
|
|
import { ConfirmationService, MenuItem, MessageService } from 'primeng/api';
|
|
|
import { Extent } from 'ol/extent';
|
|
|
import { Group, Tile, Vector as VectorLayer } from 'ol/layer';
|
|
|
@@ -19,13 +19,14 @@ import {
|
|
|
HsLayerEditorService,
|
|
|
HsEventBusService
|
|
|
} from 'hslayers-ng';
|
|
|
+import { environment } from '../../../../environments/environment';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-map',
|
|
|
templateUrl: './map.component.html',
|
|
|
styleUrls: ['./map.component.scss']
|
|
|
})
|
|
|
-export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit {
|
|
|
+export class MapComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
|
@Input('units') units: Array<{ drivers?: Drivers; generalInfo?: GeneralInfo; holder?: any; lastpos?: Lastpos; sensors?: Array<Sensor>; unit?: Unit }>;
|
|
|
mapReady: boolean = false;
|
|
|
@@ -41,18 +42,9 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit
|
|
|
public HsLayerEditorService: HsLayerEditorService,
|
|
|
public HsEventBusService: HsEventBusService
|
|
|
) {
|
|
|
- }
|
|
|
-
|
|
|
- ngAfterViewInit(): void {
|
|
|
- // this.mapReady = true;
|
|
|
-
|
|
|
- // if (this.dataReady)
|
|
|
- // this.initMap()
|
|
|
- }
|
|
|
-
|
|
|
- ngOnInit(): void {
|
|
|
this.HsConfig.update({
|
|
|
- assetsPath: 'https://unpkg.com/hslayers-ng-app@3.1.0/assets/',
|
|
|
+ assetsPath: environment.hslayersAssetsPath,
|
|
|
+ popUpDisplay: 'click',
|
|
|
proxyPrefix: window.location.hostname.includes('localhost')
|
|
|
? `${window.location.protocol}//${window.location.hostname}:8085/`
|
|
|
: '/proxy/',
|
|
|
@@ -89,17 +81,24 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit
|
|
|
mapControls: true,
|
|
|
basemapGallery: true
|
|
|
},
|
|
|
+ panelsEnabled: {
|
|
|
+ info: false, //(true by default),
|
|
|
+ layermanager: false
|
|
|
+ },
|
|
|
sidebarPosition: 'invisible',
|
|
|
queryPoint: 'hidden',
|
|
|
- // default_view: new View({
|
|
|
- // center: [1873444.3416929364, 6286508.646897761], // Latitude longitude to Spherical Mercator
|
|
|
- // extent: [1871197.0792499082, 6282949.4051418, 1873509.6915773677, 6287134.61866585],
|
|
|
- // multiWorld: false,
|
|
|
- // zoom: 6
|
|
|
- // })
|
|
|
+ // default_view: new View({
|
|
|
+ // center: [1873444.3416929364, 6286508.646897761], // Latitude longitude to Spherical Mercator
|
|
|
+ // extent: [1871197.0792499082, 6282949.4051418, 1873509.6915773677, 6287134.61866585],
|
|
|
+ // multiWorld: false,
|
|
|
+ // zoom: 6
|
|
|
+ // })
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ ngOnInit(): void {
|
|
|
+ }
|
|
|
+
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
if (changes['units']) {
|
|
|
//this.dataReady = true;
|
|
|
@@ -149,7 +148,7 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- geoJsonUnits['features'] = this.units ? this.units.filter(u => (u.lastpos.position.x > 0)).map(u => this.getUnitPos(u.lastpos)) : [];
|
|
|
+ geoJsonUnits['features'] = this.units ? this.units.filter(u => (u.lastpos.position.x > 0)).map(u => this.getUnitPos(u.lastpos, u.unit)) : [];
|
|
|
|
|
|
const vectorSource = new VectorSource({
|
|
|
features: new GeoJSON().readFeatures(geoJsonUnits),
|
|
|
@@ -161,6 +160,20 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit
|
|
|
const vectorLayer = new VectorLayer({
|
|
|
source: vectorSource,
|
|
|
style: this.styleFunction,
|
|
|
+ properties: {
|
|
|
+ popUp: {
|
|
|
+ attributes: [
|
|
|
+ {
|
|
|
+ attribute: 'id',
|
|
|
+ label: 'Unit ID'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attribute: 'desc',
|
|
|
+ label: 'Description'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
return vectorLayer;
|
|
|
@@ -181,12 +194,18 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- getUnitPos(pos: Lastpos): any {
|
|
|
+ getUnitPos(pos: Lastpos, unit: Unit): any {
|
|
|
return {
|
|
|
- 'type': 'Feature',
|
|
|
- 'geometry': {
|
|
|
- 'type': 'Point',
|
|
|
- 'coordinates': [pos.position.x, pos.position.y]
|
|
|
+ "type": "Feature",
|
|
|
+ "geometry": {
|
|
|
+ "type": "Point",
|
|
|
+ "coordinates": [pos.position.x, pos.position.y]
|
|
|
+ },
|
|
|
+ "properties": {
|
|
|
+ "id": unit.unitId,
|
|
|
+ "desc": unit.description,
|
|
|
+ "online": pos.attributes.is_online,
|
|
|
+ "moving": pos.attributes.is_moving
|
|
|
}
|
|
|
}
|
|
|
}
|