mapbox / mapbox/mapbox-gl-js

Inconsistent behavior in `getBounds`, `cameraForBounds`, `fitScreenCoordinates` and `fitBounds` with `globe` projection

Open
#11,795 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3d :triangular_ruler: bug :lady_beetle: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

When `globe` projection is used the following snippets yield inconsistent behavior when compared to `mercator` projection:

### `getBounds` and `cameraForBounds`:
```
const c = map.cameraForBounds(map.getBounds());
map.easeTo(c);
```

https://user-images.githubusercontent.com/67509069/164701266-16ce6e51-6faf-490f-94aa-74045d3ee2e7.mp4

The returned camera transform should remain the same similar to when `mercator` is in use:

https://user-images.githubusercontent.com/67509069/164701298-847b9f91-30c4-4bbf-ac70-743d6d0fb1e5.mp4

### `fitScreenCoordinates`:
```
map.fitScreenCoordinates([0, 0], [map.transform.width, map.transform.height], map.getBearing())
```

https://user-images.githubusercontent.com/67509069/164707548-bb06e6a5-52b9-4d3e-8a61-da3280a18d26.mp4

### `fitBounds`:
```
map.fitBounds(map.getBounds());
```

https://user-images.githubusercontent.com/67509069/164712924-6dee4d71-c681-473b-9971-c36d609e994f.mp4

### `boxZoom`:

https://user-images.githubusercontent.com/67509069/164719186-e14b7ae6-423f-4053-84ea-2c03f90a1b5f.mp4

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 globe-projection cases for getBounds, cameraForBounds, fitScreenCoordinates, fitBounds, and boxZoom using the snippets and recordings in the issue, then trace their camera and projection handling. Done means these operations preserve the expected camera behavior consistently with mercator, with regression coverage for the reported cases.

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
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.