File

libs/open-layers/src/lib/layers/ol-layer/ol-layer.component.ts

Description

Component to configure an additional layer to the map. The component must be embedded as seen in the example

Extends

OlBaseComponent

Implements

AfterViewInit OnChanges

Example

<n52-ol-map>
<n52-ol-layer></n52-ol-layer>
</n52-ol-map>

Metadata

selector n52-ol-layer

Index

Properties
Methods
Inputs

Inputs

layer
Type : BaseLayer

Configured layer

Methods

Private addLayer
addLayer()
Returns : void
Public mapInitialized
mapInitialized(map: Map)
Parameters :
Name Type Optional
map Map No
Returns : void
Public ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
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 :
Name Type Optional Description
map Map No
  • the created map
Returns : any
ngAfterViewInit
ngAfterViewInit()
Inherited from OlBaseComponent
Defined in OlBaseComponent:24

Subscribes for the initialization of the map after view is initialized

Returns : void

Properties

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);
    }
  }
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""