AW-6046 Angular 17
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit
This commit is contained in:
50
projects/ng-openlayers/src/lib/overlay.component.ts
Normal file
50
projects/ng-openlayers/src/lib/overlay.component.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Component, ContentChild, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { MapComponent } from './map.component';
|
||||
import Overlay, { PanOptions, Positioning } from 'ol/Overlay';
|
||||
import { ContentComponent } from './content.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: Positioning;
|
||||
@Input()
|
||||
stopEvent: boolean;
|
||||
@Input()
|
||||
insertFirst: boolean;
|
||||
@Input()
|
||||
autoPan: boolean;
|
||||
@Input()
|
||||
autoPanAnimation: PanOptions;
|
||||
@Input()
|
||||
autoPanMargin: number;
|
||||
|
||||
componentType = 'overlay';
|
||||
instance: Overlay;
|
||||
element: HTMLElement;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user