Peter Bastiani
8e8f18ad7c
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { Component, ContentChild, Input, OnDestroy, OnInit } from '@angular/core';
|
|
import { Overlay, PanOptions } from 'ol';
|
|
import OverlayPositioning from 'ol/OverlayPositioning';
|
|
import { ContentComponent } from './content.component';
|
|
import { MapComponent } from './map.component';
|
|
|
|
@Component({
|
|
selector: 'aol-overlay',
|
|
template: '<ng-content></ng-content>',
|
|
})
|
|
export class OverlayComponent implements OnInit, OnDestroy {
|
|
@ContentChild(ContentComponent, { static: true })
|
|
content: ContentComponent;
|
|
|
|
@Input()
|
|
id: number | string;
|
|
@Input()
|
|
offset: number[];
|
|
@Input()
|
|
positioning: OverlayPositioning | string;
|
|
@Input()
|
|
stopEvent: boolean;
|
|
@Input()
|
|
insertFirst: boolean;
|
|
@Input()
|
|
autoPan: boolean;
|
|
@Input()
|
|
autoPanAnimation: PanOptions;
|
|
@Input()
|
|
autoPanMargin: number;
|
|
|
|
componentType = 'overlay';
|
|
instance: Overlay;
|
|
element: Element;
|
|
|
|
constructor(private map: MapComponent) {}
|
|
|
|
ngOnInit() {
|
|
if (this.content) {
|
|
this.element = this.content.elementRef.nativeElement;
|
|
this.instance = new Overlay(this);
|
|
this.map.instance.addOverlay(this.instance);
|
|
}
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
if (this.instance) {
|
|
this.map.instance.removeOverlay(this.instance);
|
|
}
|
|
}
|
|
}
|