mapbox / mapbox/mapbox-gl-draw
add control blocked while unassociated layer tiles are loading
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
[setup.js](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/setup.js#L75) blocks adding a control until `map.loaded()` returns true.
```
if (map.loaded()) {
setup.connect();
} else {
map.on('load', setup.connect);
mapLoadedInterval = setInterval(() => { if (map.loaded()) setup.connect(); }, 16);
}
```
This is similar to issue https://github.com/mapbox/mapbox-gl-draw/issues/502. The difference between this issue and 502 is that 502 was concerned with `load` event only getting fired on initial map load. 502 has been resolved with setInterval check that polls to see of `map.loaded()` returns true. The fix for 502 allows controls to be added once all layer tiles are loaded but still blocks adding controls while layer tiles are loading. Why can't a control be added while layer tiles are loading?
Would it be possible to disable `map.loaded()` check with an option? So maybe something like
```
if (ctx.options.onAddSkipMapLoadedCheck || map.loaded()) {
setup.connect();
} else {
map.on('load', setup.connect);
mapLoadedInterval = setInterval(() => { if (map.loaded()) setup.connect(); }, 16);
}
```
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 in src/setup.js around line 75 and review the map.loaded() and interval logic, then compare the related issue #502. Determine how an option should bypass the loading check without breaking control setup, and verify that controls can be added while unassociated layer tiles are loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100