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.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<any> {
@ -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(

View File

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