import { Component , ElementRef , Output , EventEmitter } from '@angular/core' ; import { MapService } from './map.service' ; @ Component ( { selector : 'esri-map' , template : '<div><ng-content></ng-content></div>' , inputs : [ 'options' , 'itemId' ] } ) export class MapComponent { @ Output ( ) mapLoaded = new EventEmitter ( ) ; map : any ; options : Object ; itemId : string ; constructor ( private elRef , private _mapService ) { } ngOnInit ( ) { this . _mapService . createMap ( this . itemId , this . elRef . nativeElement . firstChild , this . options ) . then ( ( response ) => { this . map = response . map ; this . mapLoaded . next ( response ) ; } ) ; } setBasemap ( basemapName ) { this . _mapService . clearBasemap ( this . map ) ; this . map . setBasemap ( basemapName ) ; } ngOnDestroy ( ) { if ( this . map ) { this . map . destroy ( ) ; } } }