Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/modules/map-image/map-image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class MapImageComponent {
...x.layerConfig.options,
})
);

const mapSettings: L.MapOptions = {
zoom: settings.map.tiles.zoomLevelObservationList,
maxZoom: settings.map.tiles.maxZoom,
Expand Down
11 changes: 11 additions & 0 deletions src/app/pages/plans/plan/plan.page.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ form {
flex-direction: column;
gap: var(--spacing-medium);
}

.map {
height: 400px;
width: 100%;
}

@media screen and (max-width: 650px) {
.map {
height: 200px;
}
}
1 change: 1 addition & 0 deletions src/app/pages/plans/plan/plan.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ion-content>
<div class="content">
<div class="map" leaflet [leafletOptions]="mapOptions()" (leafletMapReady)="onMapReady($event)"></div>
<div class="tag-row">
<nve-tag saturation="default" variant="neutral">
<nve-icon slot="prefix" src="assets/icon/calendar_today.svg" />
Expand Down
65 changes: 64 additions & 1 deletion src/app/pages/plans/plan/plan.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Component, inject, input, CUSTOM_ELEMENTS_SCHEMA, computed, linkedSignal } from '@angular/core';
import { IonToolbar, IonContent, IonBackButton, IonTitle, IonHeader, IonButtons } from '@ionic/angular/standalone';
import {
IonToolbar,
IonContent,
IonBackButton,
IonTitle,
IonHeader,
IonButtons,
isPlatform,
} from '@ionic/angular/standalone';
import { GeoJSONService } from 'src/app/core/services/geojson/geojson.service';
import { DatePipe } from '@angular/common';
import 'nve-designsystem/components/nve-icon/nve-icon.component.js';
Expand All @@ -12,6 +20,13 @@ import 'nve-designsystem/components/nve-tag/nve-tag.component.js';
import { TranslatePipe } from '@ngx-translate/core';
import { Router } from '@angular/router';
import { HeaderColorDirective } from 'src/app/modules/shared/directives/header-color/header-color.directive';
import L from 'leaflet';
import { LeafletModule } from '@bluehalo/ngx-leaflet';
import { settings } from 'src/settings';
import {
MapLayersService,
OfflineCapableMapLayersService,
} from 'src/app/modules/static-map-image/static-tiles.service';

@Component({
selector: 'app-plan.page',
Expand All @@ -26,12 +41,20 @@ import { HeaderColorDirective } from 'src/app/modules/shared/directives/header-c
IonHeader,
IonTitle,
IonToolbar,
LeafletModule,
TranslatePipe,
],
providers: [
{
provide: MapLayersService,
useClass: isPlatform('hybrid') ? OfflineCapableMapLayersService : MapLayersService,
},
],
styleUrl: './plan.page.css',
})
Comment on lines 31 to 54
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component is missing the changeDetection: ChangeDetectionStrategy.OnPush setting in the decorator. This is a best practice for Angular components, especially when using signals for state management. The sibling component plans.page.ts includes this setting, and it should be added here for consistency and optimal performance.

Copilot generated this review using guidance from repository custom instructions.
export class PlanPage {
geoJSON = inject(GeoJSONService);
private mapLayersService = inject(MapLayersService);
router = inject(Router);
id = input.required<string>();

Expand All @@ -41,6 +64,45 @@ export class PlanPage {
comment = linkedSignal<string>(() => this.itemMetadata()?.comment || '');
visibleOnMap = linkedSignal<boolean>(() => this.itemMetadata()?.visibleOnMap || false);

mapOptions = computed(() => {
const mapConfig = this.mapLayersService.mapConfig();
const layersConfig = mapConfig.map((map) => ({
layerId: map.layer,
layerConfig: settings.map.tiles.topoMapLayers[map.layer],
}));
const layers = layersConfig.map((x) =>
L.tileLayer(x.layerConfig.url, {
minZoom: settings.map.tiles.minZoom,
maxZoom: settings.map.tiles.maxZoom,
updateWhenIdle: settings.map.tiles.updateWhenIdle,
...x.layerConfig.options,
})
);
const mapSettings: L.MapOptions = {
zoom: settings.map.tiles.zoomLevelObservationList,
maxZoom: settings.map.tiles.maxZoom,
minZoom: 8,
Comment thread
amish1188 marked this conversation as resolved.
bounceAtZoomLimits: false,
attributionControl: false,
zoomControl: false,
layers,
};
return mapSettings;
});
Comment thread
amish1188 marked this conversation as resolved.

async calculateAndCenterMap(map: L.Map) {
const geoJSON = await this.geoJSON.get(this.id());
if (!geoJSON) return;

const geoJsonLayer = L.geoJSON(geoJSON);
geoJsonLayer.addTo(map);
map.fitBounds(geoJsonLayer.getBounds(), { padding: [5, 5] });
}

onMapReady(map: L.Map) {
this.calculateAndCenterMap(map);
}

onNameChange(event: Event) {
const value = (event.target as HTMLInputElement).value;
this.name.set(value);
Expand All @@ -50,6 +112,7 @@ export class PlanPage {
const value = (event.target as HTMLInputElement).value;
this.comment.set(value);
}

onVisibleOnMapChange(event: Event) {
const checked = (event.target as HTMLInputElement).checked;
this.visibleOnMap.set(checked);
Expand Down