libs/open-layers/src/lib/controls/ol-mouse-position/ol-mouse-position.component.ts
Control component to show the coordinates at the mouse position
selector | n52-ol-mouse-position |
Methods |
|
Inputs |
constructor(mapService: OlMapService, mapidService: OlMapId, elementRef: ElementRef)
|
||||||||||||
Parameters :
|
projection | |
Default value : 'EPSG:3857'
|
|
mapInitialized | ||||||
mapInitialized(map: Map)
|
||||||
Parameters :
Returns :
void
|
Abstract mapInitialized | ||||||||
mapInitialized(map: Map)
|
||||||||
Inherited from
OlBaseComponent
|
||||||||
Defined in
OlBaseComponent:33
|
||||||||
This method will be triggered, when the corrsponding map is initialized.
Parameters :
Returns :
any
|
ngAfterViewInit |
ngAfterViewInit()
|
Inherited from
OlBaseComponent
|
Defined in
OlBaseComponent:24
|
Subscribes for the initialization of the map after view is initialized
Returns :
void
|
import { Component, ElementRef, Host, Input } from '@angular/core';
import { Map } from 'ol';
import { MousePosition } from 'ol/control';
import { createStringXY } from 'ol/coordinate';
import { OlBaseComponent } from '../../ol-base.component';
import { OlMapService } from '../../services/map.service';
import { OlMapId } from '../../services/mapid.service';
/**
* Control component to show the coordinates at the mouse position
*/
@Component({
selector: 'n52-ol-mouse-position',
template: '',
})
export class OlMousePositionComponent extends OlBaseComponent {
@Input() projection = 'EPSG:3857';
constructor(
protected mapService: OlMapService,
@Host() protected mapidService: OlMapId,
private elementRef: ElementRef
) {
super(mapService, mapidService);
}
mapInitialized(map: Map) {
const target = this.elementRef.nativeElement.parentElement ? this.elementRef.nativeElement : null;
const ctrl = new MousePosition({
coordinateFormat: createStringXY(4),
projection: this.projection,
undefinedHTML: ' ',
target: target
});
map.addControl(ctrl);
}
}