From 8ef1b34c3b6e30508b91e965ac2b56bf52d9ae15 Mon Sep 17 00:00:00 2001 From: tim-herbst Date: Sun, 3 Jan 2021 14:45:14 +0100 Subject: [PATCH] dynamically add and remove legend with checkbox-toggle --- .../project-3/frontend/src/app/service/map.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/project-3/frontend/src/app/service/map.service.ts b/projects/project-3/frontend/src/app/service/map.service.ts index aad157d..daee81b 100644 --- a/projects/project-3/frontend/src/app/service/map.service.ts +++ b/projects/project-3/frontend/src/app/service/map.service.ts @@ -155,9 +155,13 @@ export class MapService { marker.on('mouseout', e => e.target.closePopup()); this.drawLineOnMiniMap(marker, point); this.markerLayer.push(marker); - this.miniMap.fitBounds(L.featureGroup([...this.markerLayer, this.dashBoardMarker]).getBounds()); + this.miniMap.fitBounds(L.featureGroup([this.dashBoardMarker, ...this.markerLayer]).getBounds()); + } + if (this.polylineLayer.length === 0) { + this.legend.remove(); + } else { + this.drawLegend(); } - this.drawLegend(); } drawLegend(): void {