fitBounds() with `around` and `linear = true` don't fit given bounds.
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**: 2.4.1
**browser**: Chrome 94.0.4606.71
### Steps to Trigger Behavior
1. Create a map
2. Call `fitBounds()` with `around` set to target bounds center and `linear: true` .
3. Call `fitBounds()` a second time to fit different bounds, again with `around` set to target bounds center.
Note : `around` is set up to target bounds center as I don't want to zoom around the map absolute center but straight to target bounds.
### Link to Demonstration
https://jsfiddle.net/qmartouzet/5frts3w8/
I've set up different bounds and buttons corresponding which `fitBounds()` to those. This allows to play and observe various behaviour.
### Expected Behavior
The map fits the given bounds.
### Actual Behavior
The map fits apparently random area. It's worth noting that result area seems consistent across multiple run.
**EDIT :** Turns out, as I was looking for a workaround, that padding isn't involved in this bug. When I use `around` option set to target bounds center, successive call to `fitBounds()` produces erratic results.
**EDIT 2 :** I forgot to mention that option `linear: true` needs to be set to produce this bug.
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 by reproducing the successive fitBounds() calls from the linked JSFiddle with around set to each target bounds center and linear: true. Trace the fitBounds() entry point and related camera transition behavior; done means repeated calls fit the requested bounds rather than producing an erratic area.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100