Commit b06d9edcbb4dfd85e82c6b8cdff2e2dab521f53c

Authored by lsagona
1 parent a77940a0e4
Exists in master

fix : remove markers from map when we remove the data set

Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff

src/app/component/map/map.component.ts View file @ b06d9ed
... ... @@ -70,7 +70,7 @@
70 70 color
71 71 }).addTo(this.map);
72 72 }
73   - if (!this.circleMarkers.has(Number(message.mmsi))){
  73 + if (!this.circleMarkers.has(Number(message.mmsi))) {
74 74 this.circleMarkers.set(Number(message.mmsi), new Array<CircleMarker>());
75 75 }
76 76 this.circleMarkers.get(Number(message.mmsi)).push(circleMarker);
... ... @@ -89,8 +89,11 @@
89 89 }
90 90  
91 91 updateMap(): void {
92   - this.circleMarkers.clear();
93   - this.vessels.vessels.forEach(((vessel, key) => {
  92 + this.renderer.remove();
  93 + this.renderer = L.canvas({padding: 0.5});
  94 + this.renderer.addTo(this.map);
  95 + this.circleMarkers.forEach(value => value.splice(0, value.length));
  96 + this.vessels.vessels.forEach(((vessel) => {
94 97 const color = vessel.getColor();
95 98 vessel.messages.forEach((message) => {
96 99 this.addCircleMarker(message, color);