map.getBounds() not providing full coverage when terrain enabled
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: Latest
browser: Firefox
Steps to Trigger Behavior
- Create map with terrain layer
- Center map on "mountainous" region, wait for terrain to load, and call
getBounds()
Link to Demonstration
Creating a GeoJSON Polygon using map.getBounds() coordinates does not cover the entire map (see example and screenshots)
https://jsbin.com/lekonabole/edit?html,output
Expected Behavior
Actual Behavior
Potential solution
It appears that changing https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js#L1424 from
let tl = this.pointCoordinate(topLeft, min);
let tr = this.pointCoordinate(topRight, min);
const br = this.pointCoordinate(bottomRight, max);
const bl = this.pointCoordinate(bottomLeft, max);
to
let tl = this.pointCoordinate(topLeft, min);
let tr = this.pointCoordinate(topRight, min);
const br = this.pointCoordinate(bottomRight, min);
const bl = this.pointCoordinate(bottomLeft, min);
fixes the issue but I'm not sure if it affects other projections, etc. Just thought I'd offer it as a potential starting point.
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 with src/geo/transform.js around line 1424 and reproduce the issue using the linked JSBin with a terrain layer over a mountainous region. Compare getBounds() with the displayed map coverage and evaluate the proposed minimum-elevation change across other projections. Done means the returned bounds cover the full terrain-enabled viewport without breaking other projection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100