File

app.component.ts

Description

Main entrypoint for the data mapping application.

Show vairous layers associated with a NSHM using ArcGIS

See https://developers.arcgis.com/javascript/latest/

Implements

OnInit AfterViewInit OnDestroy

Metadata

Index

Properties
Methods

Methods

addSteps
addSteps()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

Private destroyRef
Default value : inject(DestroyRef)
navService
Default value : inject(NavigationService)
nshmpService
Default value : inject(NshmpService)
nshmpTemplateService
Default value : inject(NshmpTemplateService)
service
Default value : inject(AppService)
Private shepherdService
Default value : inject(ShepherdService)
title
Default value : apps().source.modelMaps.display

Application title

Private tutorialKey
Type : string
Default value : 'source-model-maps-show-tutorial'
Private tutorialService
Default value : inject(TutorialService)
import {AsyncPipe} from '@angular/common';
import {
  AfterViewInit,
  Component,
  DestroyRef,
  inject,
  OnDestroy,
  OnInit,
  ViewEncapsulation,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {NshmpHazardProvisionalModelComponent} from '@ghsc/nshmp-lib-ng/hazard';
import {NshmpService} from '@ghsc/nshmp-lib-ng/nshmp';
import {
  NshmpTemplateAboutComponent,
  NshmpTemplateComponent,
  NshmpTemplateContentContainerComponent,
  NshmpTemplateControlPanelComponent,
  NshmpTemplateMainContentComponent,
  NshmpTemplateService,
} from '@ghsc/nshmp-template';
import {ShepherdService} from 'angular-shepherd';
import {NavigationService} from 'projects/nshmp-apps/src/shared/services/navigation.service';
import {TutorialService} from 'projects/nshmp-apps/src/shared/services/tutorial.service';
import {apps} from 'projects/nshmp-apps/src/shared/utils/applications.utils';

import {AboutComponent} from './components/about/about.component';
import {ControlPanelComponent} from './components/control-panel/control-panel.component';
import {MapComponent} from './components/map/map.component';
import {AppService} from './services/app.service';

/**
 * Main entrypoint for the data mapping application.
 *
 * Show vairous layers associated with a NSHM using ArcGIS
 *
 * @see https://developers.arcgis.com/javascript/latest/
 */
@Component({
  encapsulation: ViewEncapsulation.None,
  imports: [
    NshmpTemplateComponent,
    NshmpTemplateContentContainerComponent,
    NshmpTemplateControlPanelComponent,
    NshmpTemplateMainContentComponent,
    NshmpHazardProvisionalModelComponent,
    NshmpTemplateAboutComponent,
    ControlPanelComponent,
    MapComponent,
    AboutComponent,
    AsyncPipe,
  ],
  selector: 'app-app',
  styleUrl: './app.component.scss',
  templateUrl: './app.component.html',
})
export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
  service = inject(AppService);
  navService = inject(NavigationService);
  nshmpTemplateService = inject(NshmpTemplateService);
  nshmpService = inject(NshmpService);
  private shepherdService = inject(ShepherdService);
  private tutorialService = inject(TutorialService);
  private destroyRef = inject(DestroyRef);

  /** Application title */
  title = apps().source.modelMaps.display;

  private tutorialKey = 'source-model-maps-show-tutorial';

  ngOnInit() {
    this.nshmpService.applicationTitle = this.title;
    this.service.init();
    this.nshmpTemplateService.showTutorialInMenu = true;

    this.nshmpTemplateService
      .startTutorial()
      .pipe(takeUntilDestroyed(this.destroyRef))
      .subscribe(() => {
        this.shepherdService.start();
      });
  }

  ngAfterViewInit(): void {
    this.addSteps();
    this.tutorialService.start(this.tutorialKey);
  }

  ngOnDestroy(): void {
    this.service.state().view.destroy();
  }

  addSteps(): void {
    this.shepherdService.addSteps([
      this.tutorialService.introStep(
        this.title,
        `
          <p>
            This application provides graphic representations of USGS national
            seismic hazard model (NSHM) components.
          </p>
        `,
      ),
      this.tutorialService.controlPanelStep(),
      this.tutorialService.applicationSettingsStep(),
      this.tutorialService.navigationStep(),
      // Map style
      {
        attachTo: {
          element: '.map-style-select',
          on: 'auto',
        },
        text: 'Change between 2D and 3D map style',
        title: 'Map Style',
      },
      this.tutorialService.nshmStep(),
      // Layer toggles
      {
        attachTo: {
          element: '.nshm-boundary-toggle',
          on: 'auto',
        },
        text: 'Toggle layers to view on map',
        title: 'Layers',
      },
      // Base layers
      this.tutorialService.arcgisBaseMapStep(),
      // Legend
      this.tutorialService.arcgisLegendStep(),
      this.tutorialService.completeStep(this.title),
    ]);
  }
}
<nshmp-template [navigationList]="navService.navigationList()" [title]="title">
  <nshmp-template-content-container [showSettingsPanel]="false">
    <nshmp-template-control-panel>
      <app-control-panel />
    </nshmp-template-control-panel>

    <nshmp-template-main-content>
      <!-- Provisional model warning -->
      <nshmp-hazard-provisional-model
        [name]="service.treesUsageResponse()?.response?.model?.name"
      />

      <app-map />
    </nshmp-template-main-content>
  </nshmp-template-content-container>

  <!-- About page -->
  <nshmp-template-about
    [applicationName]="nshmpService.applicationName$ | async"
    [applicationVersion]="(nshmpService.versionInfo$ | async)?.version ?? ''"
  >
    <app-about />
  </nshmp-template-about>
</nshmp-template>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""