[Vuejs]-Receiving 'Unhandled Promise Rejection' error

0👍

The following code creates a new id to pass to map.addSource each time targetTrackingLine is called:

let targetTrackingCalls = 0;
async targetTrackingLine() {
   const sourceId = "trace" + ++targetTrackingCalls; // unique per call

   //... source lines
   this.map.addSource(sourceId, {type: 'geojson', data: data});

   //... in timer callback;

      this.map.getSource(sourceId).setData(data);

    //...
}

Using a unique id should prevent the error raised by addSource, always assuming data is a valid geojason object per the MapBox specification

Leave a comment