File

packages/drawing/src/lib/directives/drawing-manager-trigger.ts

Implements

AfterViewInit OnDestroy

Metadata

Selector agm-map[agmDrawingManager]

Index

Methods
Inputs

Constructor

constructor(_agmMap: AgmMap)
Parameters :
Name Type Optional
_agmMap AgmMap No

Inputs

agmDrawingManager
Type : AgmDrawingManager

The drawing manager to be attached to this trigger.

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
import { AgmMap } from '@agm/core';
import { AfterViewInit, Directive, Host, Input, OnDestroy } from '@angular/core';
import { first } from 'rxjs/operators';
import { AgmDrawingManager } from './drawing-manager';

@Directive({
  selector: 'agm-map[agmDrawingManager]',
  exportAs: 'matDrawingManagerTrigger',
})
export class AgmDrawingManagerTrigger implements AfterViewInit, OnDestroy{

  /** The drawing manager to be attached to this trigger. */
  // tslint:disable-next-line: no-input-rename
  @Input('agmDrawingManager') drawingManager: AgmDrawingManager;

  constructor(@Host() private _agmMap: AgmMap) {
  }

  ngAfterViewInit(): void {
    this._agmMap.mapReady.pipe(first()).subscribe(map => this.drawingManager.setMap(map));
  }

  ngOnDestroy() {
    this._agmMap.mapReady.pipe(first()).subscribe(() => this.drawingManager.setMap(null));
  }
}

result-matching ""

    No results matching ""