forked from hpi-sam/digital-fuesim-manv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise-map.component.ts
93 lines (86 loc) · 3.24 KB
/
exercise-map.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import type { AfterViewInit, OnDestroy } from '@angular/core';
import {
Component,
ElementRef,
ViewChild,
ViewContainerRef,
} from '@angular/core';
import { Store } from '@ngrx/store';
import { Subject } from 'rxjs';
import { ExerciseService } from 'src/app/core/exercise.service';
import type { AppState } from 'src/app/state/app.state';
import {
selectCurrentRole,
selectRestrictedViewport,
} from 'src/app/state/application/selectors/shared.selectors';
import { DragElementService } from '../core/drag-element.service';
import { TransferLinesService } from '../core/transfer-lines.service';
import { OlMapManager } from './utility/ol-map-manager';
import { PopupManager } from './utility/popup-manager';
import { PopupService } from './utility/popup.service';
@Component({
selector: 'app-exercise-map',
templateUrl: './exercise-map.component.html',
styleUrls: ['./exercise-map.component.scss'],
})
export class ExerciseMapComponent implements AfterViewInit, OnDestroy {
@ViewChild('openLayersContainer')
openLayersContainer!: ElementRef<HTMLDivElement>;
@ViewChild('popoverContainer')
popoverContainer!: ElementRef<HTMLDivElement>;
@ViewChild('popoverContent', { read: ViewContainerRef })
popoverContent!: ViewContainerRef;
private readonly destroy$ = new Subject<void>();
public olMapManager?: OlMapManager;
private popupManager?: PopupManager;
public readonly restrictedToViewport$ = this.store.select(
selectRestrictedViewport
);
public readonly currentRole$ = this.store.select(selectCurrentRole);
constructor(
private readonly store: Store<AppState>,
private readonly exerciseService: ExerciseService,
public readonly dragElementService: DragElementService,
public readonly transferLinesService: TransferLinesService,
private readonly popupService: PopupService
) {}
ngAfterViewInit(): void {
this.popupManager = new PopupManager(
this.popoverContent,
this.popoverContainer.nativeElement,
this.popupService
);
this.olMapManager = new OlMapManager(
this.store,
this.exerciseService,
this.openLayersContainer.nativeElement,
this.transferLinesService,
this.popupManager,
this.popupService
);
this.dragElementService.registerMap(this.olMapManager.olMap);
this.dragElementService.registerLayerFeatureManagerDictionary(
this.olMapManager.layerFeatureManagerDictionary
);
// Check whether the map is fullscreen
this.openLayersContainer.nativeElement.addEventListener(
'fullscreenchange',
(event) => {
this.fullscreenEnabled = document.fullscreenElement !== null;
}
);
}
public fullscreenEnabled = false;
public toggleFullscreen() {
if (!this.fullscreenEnabled) {
this.openLayersContainer.nativeElement.requestFullscreen();
} else {
document.exitFullscreen();
}
}
ngOnDestroy(): void {
this.destroy$.next();
this.dragElementService.unregisterMap();
this.dragElementService.unregisterLayerFeatureManagerDictionary();
}
}