From 1936ddfe719ed4d12200c675ac152108b177fd72 Mon Sep 17 00:00:00 2001 From: Roberto Fontanarosa Date: Thu, 16 Oct 2025 13:26:51 +0200 Subject: [PATCH 1/2] Scale polygon stroke weight by zoom level --- .../main-page/map/map.component.html | 1 + .../main-page/map/map.component.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/web/src/app/pages/main-page-container/main-page/map/map.component.html b/web/src/app/pages/main-page-container/main-page/map/map.component.html index d0ac359e8..2880979bd 100644 --- a/web/src/app/pages/main-page-container/main-page/map/map.component.html +++ b/web/src/app/pages/main-page-container/main-page/map/map.component.html @@ -19,6 +19,7 @@ width="100%" [options]="mapOptions" (mapClick)="onMapClick($event)" + (zoomChanged)="onZoomChange()" > diff --git a/web/src/app/pages/main-page-container/main-page/map/map.component.ts b/web/src/app/pages/main-page-container/main-page/map/map.component.ts index 2b00060df..4d4fdeaa1 100644 --- a/web/src/app/pages/main-page-container/main-page/map/map.component.ts +++ b/web/src/app/pages/main-page-container/main-page/map/map.component.ts @@ -53,8 +53,10 @@ import {SurveyService} from 'app/services/survey/survey.service'; const normalIconScale = 30; const zoomedInLevel = 13; +const zoomCutoff = 10; const normalPolygonStrokeWeight = 3; const enlargedPolygonStrokeWeight = 6; +const highZoomPolygonStrokeWeight = 10; @Component({ selector: 'ground-map', @@ -132,6 +134,22 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { this.selectedJob$.next(this.selectedJob); } + onZoomChange() { + if (this.map.getZoom()! <= zoomCutoff) { + this.polygons?.forEach(polygons => + polygons.forEach(polygon => + polygon.setOptions({strokeWeight: highZoomPolygonStrokeWeight}) + ) + ); + } else { + this.polygons?.forEach(polygons => + polygons.forEach(polygon => + polygon.setOptions({strokeWeight: normalPolygonStrokeWeight}) + ) + ); + } + } + ngAfterViewInit() { this.subscription.add( combineLatest([ From 48c350c12d03c73ab5589f1518f472ebd317ea59 Mon Sep 17 00:00:00 2001 From: Roberto Fontanarosa Date: Thu, 16 Oct 2025 14:05:52 +0200 Subject: [PATCH 2/2] fixed bug with selected polygons --- .../main-page/map/map.component.ts | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/web/src/app/pages/main-page-container/main-page/map/map.component.ts b/web/src/app/pages/main-page-container/main-page/map/map.component.ts index 4d4fdeaa1..af0853999 100644 --- a/web/src/app/pages/main-page-container/main-page/map/map.component.ts +++ b/web/src/app/pages/main-page-container/main-page/map/map.component.ts @@ -135,19 +135,21 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { } onZoomChange() { - if (this.map.getZoom()! <= zoomCutoff) { - this.polygons?.forEach(polygons => - polygons.forEach(polygon => - polygon.setOptions({strokeWeight: highZoomPolygonStrokeWeight}) - ) - ); - } else { - this.polygons?.forEach(polygons => - polygons.forEach(polygon => - polygon.setOptions({strokeWeight: normalPolygonStrokeWeight}) - ) - ); - } + const currentZoom = this.map.getZoom()!; + + const newStrokeWeight = + currentZoom <= zoomCutoff + ? highZoomPolygonStrokeWeight + : normalPolygonStrokeWeight; + + this.polygons?.forEach(polygons => + polygons.forEach(polygon => { + if (!polygon.get('selected')) + polygon.setOptions({ + strokeWeight: newStrokeWeight, + }); + }) + ); } ngAfterViewInit() { @@ -680,9 +682,10 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { const polygons = this.polygons.get(locationOfInterestId); - polygons?.forEach(polygon => - polygon.setOptions({strokeWeight: enlargedPolygonStrokeWeight}) - ); + polygons?.forEach(polygon => { + polygon.set('selected', true); + polygon.setOptions({strokeWeight: enlargedPolygonStrokeWeight}); + }); this.fitMapToLocationsOfInterest( this.getLoisByIds(List([locationOfInterestId])) @@ -696,11 +699,12 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { this.selectedLocationOfInterestId ); - selectedPolygons?.forEach(polygon => + selectedPolygons?.forEach(polygon => { + polygon.set('selected', false); polygon.setOptions({ strokeWeight: normalPolygonStrokeWeight, - }) - ); + }); + }); } /**