mapbox / mapbox/mapbox-gl-directions
How to know exactly when to prompt the user that he has to turn
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 255
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm using this plugin to develop an app that has to transmit to an arduino device when the user should turn right/left/U and have a couple of questions.
My first question is this one:
Unfortunately, I don't see any instructions nor steps in my `Directions` object, even if I set them to "true". Is there a way to access them ? The route is well displayed so far.
Here's my code:
```
let directions = new MapboxDirections({
accessToken: environment.mapbox.accessToken,
unit: 'metric',
profile: 'mapbox/cycling',
interactive: false,
steps: true,
instructions: true,
controls: {
inputs: false,
instructions: true,
profileSwitcher: false
}
});
this.map.addControl(directions);
directions.setOrigin([this.userLocation.coords.longitude, this.userLocation.coords.latitude]);
directions.setDestination([this.selectedAddress.geometry.coordinates[0],
this.selectedAddress.geometry.coordinates[1]]);
console.log(directions);
```
My second question:
Is there a way to override normal direction panel instructions (like, I don't know, maybe detecting when the panel's DOM changes, when an instruction gets bold (current instruction) ? Or do I need to calculate distance between location of the user and next step's coordinates in a loop ?
Thanks in advance for the help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the MapboxDirections options shown in the report and how the Directions object exposes route steps and instructions. Then inspect the instructions control and its current-step behavior in the plugin. Done would require a documented or implemented way to access turn instructions and identify the active instruction, but the issue does not name files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100