components/map/map.component.ts
ArcGIS map with layers showing NSHM boundary, fault sections, and test sites.
OnInit
encapsulation | ViewEncapsulation.None |
selector | app-map |
imports |
LegendComponent
NshmpMapArcgisComponent
NshmpMapArcgis3dComponent
MatButtonModule
MatMenuModule
NgTemplateOutlet
|
templateUrl | ./map.component.html |
styleUrl | ./map.component.scss |
Properties |
Methods |
constructor(service: AppService, destroyRef: DestroyRef)
|
|||||||||
Defined in components/map/map.component.ts:47
|
|||||||||
Parameters :
|
Private goTo | ||||||
goTo(layer: GeoJSONLayer)
|
||||||
Defined in components/map/map.component.ts:79
|
||||||
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in components/map/map.component.ts:59
|
Returns :
void
|
viewReady | ||||||
viewReady(view: ___esri.MapView | ___esri.SceneView)
|
||||||
Defined in components/map/map.component.ts:67
|
||||||
Parameters :
Returns :
void
|
Private init |
Default value : false
|
Defined in components/map/map.component.ts:47
|
mapStyle |
Default value : this.service.formGroup.controls.mapStyle
|
Defined in components/map/map.component.ts:44
|
Public service |
Type : AppService
|
Defined in components/map/map.component.ts:50
|
Private view |
Type : MapView | SceneView
|
Defined in components/map/map.component.ts:46
|
import '@arcgis/map-components/dist/components/arcgis-legend';
import '@arcgis/map-components/dist/components/arcgis-placement';
import {NgTemplateOutlet} from '@angular/common';
import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
DestroyRef,
effect,
OnInit,
ViewEncapsulation,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {MatButtonModule} from '@angular/material/button';
import {MatMenuModule} from '@angular/material/menu';
import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer';
import MapView from '@arcgis/core/views/MapView';
import SceneView from '@arcgis/core/views/SceneView';
import {NshmpMapArcgis3dComponent, NshmpMapArcgisComponent} from '@ghsc/nshmp-lib-ng/map';
import {from} from 'rxjs';
import {AppService} from '../../services/app.service';
import {LegendComponent} from '../legend/legend.component';
/**
* ArcGIS map with layers showing NSHM boundary, fault sections, and test sites.
*/
@Component({
encapsulation: ViewEncapsulation.None,
imports: [
LegendComponent,
NshmpMapArcgisComponent,
NshmpMapArcgis3dComponent,
MatButtonModule,
MatMenuModule,
NgTemplateOutlet,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
selector: 'app-map',
styleUrl: './map.component.scss',
templateUrl: './map.component.html',
})
export class MapComponent implements OnInit {
mapStyle = this.service.formGroup.controls.mapStyle;
private view: MapView | SceneView;
private init = false;
constructor(
public service: AppService,
private destroyRef: DestroyRef,
) {
effect(() => {
const layer = this.service.layers().nshmBoundaryLayer;
this.goTo(layer);
});
}
ngOnInit(): void {
const {mapStyle} = this.service.formGroup.controls;
mapStyle.valueChanges
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(mapStyle => this.service.onMapStyleChange(mapStyle));
}
viewReady(view: __esri.MapView | __esri.SceneView): void {
this.view = view;
if (this.init) {
this.service.onMapViewChange();
const layer = this.service.layers().nshmBoundaryLayer;
this.goTo(layer);
}
this.init = true;
}
private goTo(layer: GeoJSONLayer): void {
if (this.view && layer) {
from(layer.when())
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
from(this.view.goTo(layer.fullExtent))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe();
});
}
}
}
@if (mapStyle.getRawValue() === '2d') {
<nshmp-map-arcgis [map]="service.map2d" (viewReady)="viewReady($event.view)">
<ng-container *ngTemplateOutlet="legend" />
</nshmp-map-arcgis>
} @else {
<nshmp-map-arcgis-3d [map]="service.map3d" (viewReady)="viewReady($event.view)">
<ng-container *ngTemplateOutlet="legend" />
</nshmp-map-arcgis-3d>
}
<ng-template #legend>
<arcgis-placement position="top-right">
<div class="legend">
<button mat-fab [matMenuTriggerFor]="menu" #menuTrigger="matMenuTrigger">
<img src="assets/map/legend.png" />
</button>
<mat-menu
#menu="matMenu"
xPosition="before"
[hasBackdrop]="false"
panelClass="panel-class"
overlayPanelClass="overlay-panel-class"
backdropClass="backdrop-class"
>
<div (click)="$event.stopPropagation()" class="model-maps-legend">
<div class="padding-2">
<button mat-raised-button (click)="menuTrigger.closeMenu()" class="grid-col-12">
Close
</button>
</div>
<app-legend />
</div>
</mat-menu>
</div>
</arcgis-placement>
</ng-template>