File

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

Description

Defines an abstract class, which must be implemented by every additional component

Implements

AfterViewInit

Index

Methods

Constructor

constructor(mapService: OlMapService, mapidService: OlMapId)

Creates an instance of OlBaseComponent. A map service and the corresponding map id of the parent map will be injected

Parameters :
Name Type Optional
mapService OlMapService No
mapidService OlMapId No

Methods

Abstract mapInitialized
mapInitialized(map: Map)

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()

Subscribes for the initialization of the map after view is initialized

Returns : void
import { AfterViewInit, Host } from '@angular/core';
import Map from 'ol/Map.js';

import { OlMapService } from './services/map.service';
import { OlMapId } from './services/mapid.service';


/**
 * Defines an abstract class, which must be implemented by every additional component
 */
export abstract class OlBaseComponent implements AfterViewInit {

  /**
   * Creates an instance of OlBaseComponent. A map service and the corresponding map id of the parent map will be injected
   */
  constructor(
    protected mapService: OlMapService,
    @Host() protected mapidService: OlMapId
  ) { }

  /**
   * Subscribes for the initialization of the map after view is initialized
   */
  ngAfterViewInit(): void {
    this.mapidService.getId().subscribe(id => this.mapService.getMap(id).subscribe(map => this.mapInitialized(map)));
  }

  /**
   * This method will be triggered, when the corrsponding map is initialized.
   * @abstract
   * @param {Map} map - the created map
   */
  abstract mapInitialized(map: Map);

}

result-matching ""

    No results matching ""