import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core'; import MousePosition from 'ol/control/MousePosition'; import { MapComponent } from '../map.component'; import { CoordinateFormat } from 'ol/coordinate'; import { ProjectionLike } from 'ol/proj'; @Component({ selector: 'aol-control-mouseposition', template: ``, }) export class ControlMousePositionComponent implements OnInit, OnDestroy { @Input() coordinateFormat: CoordinateFormat; @Input() projection: ProjectionLike; instance: MousePosition; target: HTMLElement; constructor( private map: MapComponent, private element: ElementRef ) {} ngOnInit() { this.target = this.element.nativeElement; // console.log('ol.control.MousePosition init: ', this); this.instance = new MousePosition(this); this.map.instance.addControl(this.instance); } ngOnDestroy() { // console.log('removing aol-control-mouseposition'); this.map.instance.removeControl(this.instance); } }