mapbox / mapbox/mapbox-gl-js

Adding vector layer to map with map.addLayer will not always make the layer visible until next navigation

Open
#13,467 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs information :pray:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**:v3.7.0

**browser**:chrome

### Steps to Trigger Behavior
This does not always happen, it seems to be more likely to happen if the layer has lots of features.
It seems to be even more likely to happen if another layer with lots of features are already added to the map, so this is what I will based the repro steps on.

1. Add source used by layer A, alyways a url to an xyz tileset
2. Add layer A
3. Add source used by layer B, alyways a url to an xyz tileset
4. Add layer B
5. Notice that layer A is still visible, but layer B is not.
6. Move the camera
7. Notice that layer A and layer B is visible.

I have managed to work around the issue by popping a panBy[0,0] at the first idle event from the map. Popping it directly after adding the layer has no effect.

### Expected Behavior
I expect to see all layers added to the map

### Actual Behavior
Some layers does not show until after navigation

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 reproducing the issue with the listed map.addLayer sequence, especially large XYZ tile layers, and observe the idle and panBy([0,0]) behavior. Trace the map.addLayer and rendering lifecycle to determine why the second layer waits for navigation; done means newly added layers are visible without moving the camera.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics, frontend
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.