import { ChangeDetectionStrategy, Component, ElementRef, OnInit, ViewEncapsulation } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { AxAuthenticationService } from '@atlasx/core/authentication'

import { GisService } from './gis.service'


@Component({
  selector: 'app-gis',
  templateUrl: './gis.component.html',
  styleUrls: ['./gis.component.scss'],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class GisComponent implements OnInit {

  constructor(
    private route: ActivatedRoute,
    private hostRef: ElementRef<HTMLElement>,
    public gisService: GisService,
    public authService: AxAuthenticationService
  ) { }

  async ngOnInit() {
    // Get functions from system id.
    const systemId: string = this.route.snapshot.data.systemId
    this.gisService.loadFunctions(systemId)

    // Create a new map.
    await this.gisService.createMap(this.hostRef.nativeElement)
  }

}
