mapbox / mapbox-gl-directions

Directions plugin for mapbox-gl-js using Mapbox Directions API.
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
ISC License
237 stars 123 forks source link

Ability to add multiple waypoints at once #192

Open hughjdavey opened 6 years ago

hughjdavey commented 6 years ago

It would be great if the plugin API could have a method like addWaypoints() to complement the existing addWaypoint() method. The reason for this is that displaying a route with multiple waypoints can result in rate limit issues as we are forced to do something like [simplified]:

this.directions
  .setOrigin(origin)
  .setDestination(destination);

waypoints.forEach((waypoint, index) => {
  this.directions.addWaypoint(index, waypoint);    // a request each time
});

which results in multiple fast requests. This should be possible as the underlying directions API allows adding multiple points to a single request. So I suppose what I am asking to be possible is something like:

this.directions
  .setOrigin(origin)
  .setDestination(destination)
  .setWaypoints(waypoints);

Let me know if I have done something wrong or asked in the wrong place, and thanks for your time :)

AshwinTayson commented 5 years ago

Any updates on this?

IJaouhar commented 5 years ago

Updates?

lywinged commented 5 years ago

need updates....