mapbox / mapbox/mapbox-gl-directions

Ability to add multiple waypoints at once

Open
#192 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged enhancement
Dominant language
JavaScript
Stars
255
Forks
130
PR merge metrics
No merged PRs in 30d

Description

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]:

```typescript
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:

```typescript
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 :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing addWaypoint() plugin API and follow how it builds and sends directions requests. Compare the requested addWaypoints() or setWaypoints() entry point with the underlying Directions API; done means multiple waypoints can be submitted in one request without repeated fast requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.