From b06d9edcbb4dfd85e82c6b8cdff2e2dab521f53c Mon Sep 17 00:00:00 2001 From: lsagona Date: Mon, 23 Nov 2020 15:46:35 +0100 Subject: [PATCH] fix : remove markers from map when we remove the data set --- src/app/component/map/map.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/component/map/map.component.ts b/src/app/component/map/map.component.ts index 43e05db..a6cd499 100644 --- a/src/app/component/map/map.component.ts +++ b/src/app/component/map/map.component.ts @@ -70,7 +70,7 @@ export class MapComponent implements OnInit { color }).addTo(this.map); } - if (!this.circleMarkers.has(Number(message.mmsi))){ + if (!this.circleMarkers.has(Number(message.mmsi))) { this.circleMarkers.set(Number(message.mmsi), new Array()); } this.circleMarkers.get(Number(message.mmsi)).push(circleMarker); @@ -89,8 +89,11 @@ export class MapComponent implements OnInit { } updateMap(): void { - this.circleMarkers.clear(); - this.vessels.vessels.forEach(((vessel, key) => { + this.renderer.remove(); + this.renderer = L.canvas({padding: 0.5}); + this.renderer.addTo(this.map); + this.circleMarkers.forEach(value => value.splice(0, value.length)); + this.vessels.vessels.forEach(((vessel) => { const color = vessel.getColor(); vessel.messages.forEach((message) => { this.addCircleMarker(message, color); -- 1.7.10.4