fix table and marker generation

This commit is contained in:
tim-herbst 2020-12-30 12:32:02 +01:00
parent b9080f64b0
commit 4525c10207
2 changed files with 14 additions and 1 deletions

View File

@ -144,6 +144,7 @@ export class DashboardComponent implements OnInit {
}) })
}); });
this.changeDetectorRefs.detectChanges(); this.changeDetectorRefs.detectChanges();
this.map.removeTableStationMarkerOnReload();
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.service.fetchDashboardInit(params.id).then(data => { this.service.fetchDashboardInit(params.id).then(data => {
this.station = data; this.station = data;
@ -233,7 +234,6 @@ export class DashboardComponent implements OnInit {
}; };
}); });
}); });
} }
async initDashboard(): Promise<any> { async initDashboard(): Promise<any> {
@ -379,12 +379,14 @@ export class DashboardComponent implements OnInit {
onSubmit(): void { onSubmit(): void {
this.actualStartDate = this.form.get('daterange').value.start; this.actualStartDate = this.form.get('daterange').value.start;
this.actualEndDate = this.form.get('daterange').value.end; this.actualEndDate = this.form.get('daterange').value.end;
this.map.removeTableStationMarkerOnReload();
this.service.fetchDashboardStationTo( this.service.fetchDashboardStationTo(
this.station.id, this.station.id,
this.actualStartDate.toISOString().substring(0, 10), this.actualStartDate.toISOString().substring(0, 10),
this.actualEndDate.toISOString().substring(0, 10) this.actualEndDate.toISOString().substring(0, 10)
).then((source) => { ).then((source) => {
this.stationToSource = source; this.stationToSource = source;
this.selectionTo.clear();
this.changeDetectorRefs.detectChanges(); this.changeDetectorRefs.detectChanges();
}); });
this.service.fetchDashboardStationFrom( this.service.fetchDashboardStationFrom(
@ -393,6 +395,7 @@ export class DashboardComponent implements OnInit {
this.actualEndDate.toISOString().substring(0, 10) this.actualEndDate.toISOString().substring(0, 10)
).then((source) => { ).then((source) => {
this.stationFromSource = source; this.stationFromSource = source;
this.selectionFrom.clear();
this.changeDetectorRefs.detectChanges(); this.changeDetectorRefs.detectChanges();
}); });
this.service.fetchDashboardStationCharts( this.service.fetchDashboardStationCharts(

View File

@ -140,11 +140,21 @@ export class MapService {
this.dashBoardMarker = L.marker([lat, lon], {icon: createIcon('blue')}).addTo(this.miniMap); 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 { public drawTableStationMarker(bikePoints: any[]): void {
if (this.markerLayer) { if (this.markerLayer) {
this.markerLayer.forEach(marker => { this.markerLayer.forEach(marker => {
this.miniMap.removeLayer(marker); this.miniMap.removeLayer(marker);
}); });
this.markerLayer = [];
} }
for (const point of bikePoints) { for (const point of bikePoints) {
const marker = L.marker([point.stationLat, point.stationLon], {icon: createIcon(point.color)}).addTo(this.miniMap); const marker = L.marker([point.stationLat, point.stationLon], {icon: createIcon(point.color)}).addTo(this.miniMap);