Abrupt colorGreenspace changes at zoom level 11
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
### mapbox-gl-js version
v3.19.0
### Browser and version
chrome 145.0.7632.117
### Expected behavior
There should be less of a color change when zooming at level 11. The transition in v3.9.3 and v3.11.1 seem to have a smooth color fade, while v3.19.0 does not.
https://github.com/user-attachments/assets/9fe6b24f-db2e-430b-8d1c-f1a19c9b52ff
https://github.com/user-attachments/assets/7fef75c6-611b-4af3-b720-86468a2a3782
As a temporary fix, I added a zoom-based interpolation to control the opacity of `colorGreenspace`
map.on('zoom', () => {
const transitionZoom = map?.getZoom() ?? 3.5;
if (baseMapStyle !== 'satellite') {
const minOpacityValue = 0.25;
const maxOpacityValue = 0.9;
const startZoom = 6;
const endZoom = 11;
const zoomInterpolationFactor = Math.min(
1,
Math.max(0, (transitionZoom - startZoom) / (endZoom - startZoom)),
);
const opacity = Number(
(
maxOpacityValue -
zoomInterpolationFactor * (maxOpacityValue - minOpacityValue)
).toFixed(2),
);
map?.setConfigProperty('basemap', 'colorGreenspace', `hsla(115, 60%, 84%, ${opacity})`);
}
});
### Actual behavior
The colors change abruptly at zoom level 11. Seems to happen when the map adds more detail.
https://github.com/user-attachments/assets/454e0054-3e22-421e-b382-5aa5370e2125
https://github.com/user-attachments/assets/43f1b599-9ede-474f-a0e3-9d64dd52046b
### Link to the demonstration
_No response_
### Steps to trigger the unexpected behavior
1. zoom to level 11
2. Zoom in and out where the map adds more detail
### Relevant log output
```shell
```
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
Reproduce the abrupt colorGreenspace change in mapbox-gl-js v3.19.0 by zooming around level 11, then compare it with v3.9.3 and v3.11.1. Trace how basemap colorGreenspace and added map detail are handled across that zoom boundary; done means the transition is as smooth as the expected behavior shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- 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