title: Angular : remove a Leaflet polyline between 2 markers
body: <p>While i am using <code>interval</code> to update data json coordinates , i have connection path" between the last and the first point crossed original path of data json . </p>
  
  <p><a href="https://i.stack.imgur.com/Sdavp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sdavp.png" alt="enter image description here"></a></p>
  
  <p>So how can i remove the "connection path" between the last and the first point marker ? </p>
  
  <p>Code : </p>
  
  <pre><code>export class MapTrackBeforPage implements OnInit {
      map: Map;
      poly:L.Polyline
  
      protected points: { lat: number, lng: number }[] = [];
  
      constructor(
          private http: HTTP,
         public zone : NgZone) {
  
      }
  
      ionViewDidEnter() {
          this.getmarker()
      }
  
  
      async getmarker() {
  
          this.zone.runTask(()=&gt;{
              setInterval(()=&gt;{
                  this.http.get('xxxxxxxxxxxxxxxxxx'', {}, {})
                  .then(data =&gt; {
                                                             -------------Polyline path ---------
              for (let datas of JSON.parse(data.data)['trail']) {
  
              this.points.push({ lat: datas.lat, lng: datas.lng })
  
              let poly = new L.Polyline([this.points], { color: 'red', weight: 3}).addTo(this.map);
  
  
              }
  
               })
              },5000)
          })
  
      }
  
  }
  </code></pre>