mapbox / mapbox/mapbox-gl-traffic

Does not load traffic layer by default

Open
#9 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
108
Forks
36
PR merge metrics
No merged PRs in 30d

Description

This can not show traffic by default, I have to press the traffic button twice to cycle it. there does not seem to be a working method to show traffic on load.

My code looks like this:

`
mapboxgl.accessToken = 'redacted_privatekey_';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
zoom: 8,
center: [-122, 47.8],
});
map.on('load', function() {
map.addControl(new mapboxgl.NavigationControl());
map.addControl(new MapboxTraffic({showTraffic: true}));
});
`

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 MapboxTraffic control and its handling of the showTraffic option, then reproduce the issue with the map initialization snippet in this report. Done means traffic is visible immediately after the map loads with showTraffic enabled, without pressing the traffic button twice.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.