0

I'm working with mapbox gl directions, I can start the map, and create the directions from point A to B, but I got a issue when I add more waypoints, if I try to move the traced route in the waypoint A.a and A.b, the result doesn't respect the array order

results

If I move from index 1 to 2, the result must add the new coordinates between the index 1 and 2, but it add the result between the 0 and 1.

My code is simple, I don't know if I'm missing something

let firstElement = route[0].location;

let lasIndex = (route.length - 1)

let lastElement = route[lasIndex].location;

let waypoints = route.slice(1, -1)

this.directions.setOrigin(firstElement);

waypoints.forEach((element, index) => {
  
  this.directions.addWaypoint(index, element.location);
  
});

this.directions.setDestination(lastElement);

hope someone can helpe me to solve this problem

cesg.dav
  • 320
  • 1
  • 14

0 Answers0