From 4525c10207449324b8eb9989351c9ac7d4354fc8 Mon Sep 17 00:00:00 2001 From: tim-herbst Date: Wed, 30 Dec 2020 12:32:02 +0100 Subject: [PATCH] fix table and marker generation --- .../frontend/src/app/dashboard/dashboard.component.ts | 5 ++++- .../project-3/frontend/src/app/service/map.service.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts index bc0b410..fa0ba73 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts @@ -144,6 +144,7 @@ export class DashboardComponent implements OnInit { }) }); this.changeDetectorRefs.detectChanges(); + this.map.removeTableStationMarkerOnReload(); this.route.params.subscribe(params => { this.service.fetchDashboardInit(params.id).then(data => { this.station = data; @@ -233,7 +234,6 @@ export class DashboardComponent implements OnInit { }; }); }); - } async initDashboard(): Promise { @@ -379,12 +379,14 @@ export class DashboardComponent implements OnInit { onSubmit(): void { this.actualStartDate = this.form.get('daterange').value.start; this.actualEndDate = this.form.get('daterange').value.end; + this.map.removeTableStationMarkerOnReload(); this.service.fetchDashboardStationTo( this.station.id, this.actualStartDate.toISOString().substring(0, 10), this.actualEndDate.toISOString().substring(0, 10) ).then((source) => { this.stationToSource = source; + this.selectionTo.clear(); this.changeDetectorRefs.detectChanges(); }); this.service.fetchDashboardStationFrom( @@ -393,6 +395,7 @@ export class DashboardComponent implements OnInit { this.actualEndDate.toISOString().substring(0, 10) ).then((source) => { this.stationFromSource = source; + this.selectionFrom.clear(); this.changeDetectorRefs.detectChanges(); }); this.service.fetchDashboardStationCharts( 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 3801a68..0d280ba 100644 --- a/projects/project-3/frontend/src/app/service/map.service.ts +++ b/projects/project-3/frontend/src/app/service/map.service.ts @@ -140,11 +140,21 @@ export class MapService { this.dashBoardMarker = L.marker([lat, lon], {icon: createIcon('blue')}).addTo(this.miniMap); } + public removeTableStationMarkerOnReload(): void { + if (this.markerLayer) { + this.markerLayer.forEach(marker => { + this.miniMap.removeLayer(marker); + }); + this.markerLayer = []; + } + } + public drawTableStationMarker(bikePoints: any[]): void { if (this.markerLayer) { this.markerLayer.forEach(marker => { this.miniMap.removeLayer(marker); }); + this.markerLayer = []; } for (const point of bikePoints) { const marker = L.marker([point.stationLat, point.stationLon], {icon: createIcon(point.color)}).addTo(this.miniMap);