FarmMapsLib/projects/ng-openlayers/src/lib/controls/zoomtoextent.component.ts

36 lines
885 B
TypeScript

import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { ZoomToExtent } from 'ol/control';
import { MapComponent } from '../map.component';
import { Extent } from 'ol/extent';
@Component({
selector: 'aol-control-zoomtoextent',
template: ` <ng-content></ng-content> `,
})
export class ControlZoomToExtentComponent implements OnInit, OnDestroy {
@Input()
className: string;
@Input()
label: string | HTMLElement;
@Input()
tipLabel: string;
@Input()
extent: Extent;
instance: ZoomToExtent;
constructor(private map: MapComponent) {
// console.log('instancing aol-control-zoomtoextent');
}
ngOnInit() {
this.instance = new ZoomToExtent(this);
this.map.instance.addControl(this.instance);
}
ngOnDestroy() {
// console.log('removing aol-control-zoomtoextent');
this.map.instance.removeControl(this.instance);
}
}