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:
35
projects/ng-openlayers/src/lib/feature.component.ts
Normal file
35
projects/ng-openlayers/src/lib/feature.component.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Component, OnInit, OnDestroy, OnChanges, Input, SimpleChanges } from '@angular/core';
|
||||
import { Feature } from 'ol';
|
||||
import { SourceVectorComponent } from './sources/vector.component';
|
||||
|
||||
@Component({
|
||||
selector: 'aol-feature',
|
||||
template: ` <ng-content></ng-content> `,
|
||||
})
|
||||
export class FeatureComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Input()
|
||||
id: string | number | undefined;
|
||||
|
||||
public componentType = 'feature';
|
||||
public instance: Feature;
|
||||
|
||||
constructor(private host: SourceVectorComponent) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.instance = new Feature();
|
||||
if (this.id !== undefined) {
|
||||
this.instance.setId(this.id);
|
||||
}
|
||||
this.host.instance.addFeature(this.instance);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.host.instance.removeFeature(this.instance);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (this.instance) {
|
||||
this.instance.setId(this.id);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user