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);