libs/open-layers/src/lib/layers/ol-layer/ol-layer.component.ts
Component to configure an additional layer to the map. The component must be embedded as seen in the example
<n52-ol-map>
<n52-ol-layer></n52-ol-layer>
</n52-ol-map>
selector | n52-ol-layer |
Properties |
|
Methods |
|
Inputs |
layer | |
Type : BaseLayer
|
|
Configured layer |
Private addLayer |
addLayer()
|
Returns :
void
|
Public mapInitialized | ||||||
mapInitialized(map: Map)
|
||||||
Parameters :
Returns :
void
|
Public ngOnChanges | ||||||
ngOnChanges(changes: SimpleChanges)
|
||||||
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
|
Private map |
Type : Map
|
import { AfterViewInit, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Map } from 'ol';
import BaseLayer from 'ol/layer/Base';
import { OlBaseComponent } from '../../ol-base.component';
/**
* Component to configure an additional layer to the map. The component must be embedded as seen in the example
*
* @example
* <n52-ol-map>
* <n52-ol-layer></n52-ol-layer>
* </n52-ol-map>
*/
@Component({
selector: 'n52-ol-layer',
template: '',
})
export class OlLayerComponent extends OlBaseComponent implements AfterViewInit, OnChanges {
/**
* Configured layer
*/
@Input() layer: BaseLayer;
private map: Map;
public ngOnChanges(changes: SimpleChanges): void {
if (changes && this.layer) {
this.addLayer();
}
}
public mapInitialized(map: Map) {
this.map = map;
this.addLayer();
}
private addLayer() {
if (this.map && this.layer) {
this.map.addLayer(this.layer);
}
}
}