mapbox / mapbox/mapbox-gl-directions

setOrigin and setDestination changing others maps directions

Open
#170 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
JavaScript
Stars
255
Forks
130
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have 2 classes with 2 differents maps with differents containers.
When i made changes on one map, this is independant from the other map, excepts for setOrigin and setDestination. Those 2 functions impacts the two independants directions instances.

Class 1
```
this.map1 = new mapboxgl.Map({
container: 'map1',
style: 'mapbox://styles/mapbox/streets-v10',
});

this.directions1 = new MapboxDirections({
accessToken: mapboxgl.accessToken,
unit: 'metric',
profile: 'walking',
interactive: false,
controls: {
inputs: false,
instructions: false,
profileSwitcher: false
}
});
this.map1.addControl(this.directions);
...
this.directions1.setOrigin([lon, lat]);
this.directions1.setDestination([lon+1, lat+1]);
```

Class 2
```
this.map2 = new mapboxgl.Map({
container: 'map2',
style: 'mapbox://styles/mapbox/streets-v10',
});

this.directions2 = new MapboxDirections({
accessToken: mapboxgl.accessToken,
unit: 'metric',
profile: 'walking',
interactive: false,
controls: {
inputs: false,
instructions: false,
profileSwitcher: false
}
});
this.map2.addControl(this.directions);
...
this.directions2.setOrigin([lon+3, lat+3]);
this.directions2.setDestination([lon+3, lat+3]);
```

Problem : the setOrigin and setDestination from directions2 impacts the direction1 instance.

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

Reproduce the issue with the two MapboxDirections instances and the setOrigin and setDestination calls shown in the report. Inspect how those methods update direction state, then verify that changing directions2 leaves directions1 unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.