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
MatButtonModule
MatMenuModule
MatIcon
|
templateUrl | ./map.component.html |
styleUrl | ./map.component.scss |
Properties |
|
Methods |
Private goTo | ||||||
goTo(layer: ___esri.Layer)
|
||||||
Defined in components/map/map.component.ts:72
|
||||||
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in components/map/map.component.ts:44
|
Returns :
void
|
viewReady | ||||||
viewReady(view: ___esri.MapView)
|
||||||
Defined in components/map/map.component.ts:61
|
||||||
Parameters :
Returns :
void
|
Private destroyRef |
Default value : inject(DestroyRef)
|
Defined in components/map/map.component.ts:37
|
Private init |
Default value : false
|
Defined in components/map/map.component.ts:42
|
mapOptions |
Default value : signal<ArcgisMapOptions>({})
|
Defined in components/map/map.component.ts:39
|
service |
Default value : inject(AppService)
|
Defined in components/map/map.component.ts:36
|
Private view |
Type : MapView | SceneView
|
Defined in components/map/map.component.ts:41
|
import '@arcgis/map-components/dist/components/arcgis-placement';
import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
DestroyRef,
inject,
OnInit,
signal,
ViewEncapsulation,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {MatButtonModule} from '@angular/material/button';
import {MatIcon} from '@angular/material/icon';
import {MatMenuModule} from '@angular/material/menu';
import MapView from '@arcgis/core/views/MapView';
import SceneView from '@arcgis/core/views/SceneView';
import {ArcgisMapOptions, ArcLayerId, 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, MatButtonModule, MatMenuModule, MatIcon],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
selector: 'app-map',
styleUrl: './map.component.scss',
templateUrl: './map.component.html',
})
export class MapComponent implements OnInit {
service = inject(AppService);
private destroyRef = inject(DestroyRef);
mapOptions = signal<ArcgisMapOptions>({});
private view: MapView | SceneView;
private init = false;
ngOnInit(): void {
const {model} = this.service.formGroup.controls;
model.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(model => {
if (model !== null && this.service.sourceFeaturesUsage()) {
const title = this.service.sourceFeaturesUsage().response.model.name;
this.mapOptions.set({
print: {
dpi: 200,
title,
},
});
}
});
}
viewReady(view: __esri.MapView): void {
this.view = view;
this.service.updateState({view});
view.on('layerview-create', viewEvent => {
if (viewEvent.layer.id === ArcLayerId.NSHM.toString()) {
this.goTo(viewEvent.layer);
}
});
}
private goTo(layer: __esri.Layer): void {
if (this.view && layer) {
from(layer.when())
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
from(this.view.goTo(layer.fullExtent))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe();
});
}
}
}
<nshmp-map-arcgis
[map]="service.map"
[mapOptions]="mapOptions()"
(viewReady)="viewReady($event.view)"
>
<arcgis-placement position="top-right">
<div class="legend">
<button mat-fab [matMenuTriggerFor]="menu" #menuTrigger="matMenuTrigger">
<mat-icon>vpn_key</mat-icon>
</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>
</nshmp-map-arcgis>