mapbox / mapbox/mapbox-gl-js

map.fitBounds() with bearing does not fit the entire bounds

Open
#10,064 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle: good first issue
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

When `map.fitBounds(...)` is called with a bearing option passed in, it seems like the bearing is not taken into the account on calculating the appropriate zoom, resulting in part of the bounded area to not be in view.

**mapbox-gl-js version**: 1.12.0

**browser**: Chrome

### Steps to Trigger Behavior

1. Create a bounded area with a list of coordinates
2. Call `map.fitBounds(...)` with bearing option set

### Link to Demonstration

https://jsfiddle.net/_blahblahblah/k4vL6s5r/

### Expected Behavior

When clicking on the 'Fit to Line at 29º Bearing' button in the demo link, all 6 stations should be in view.

### Actual Behavior

Only 4 of the 6 stations are in view.

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 with the map.fitBounds(...) entry point and reproduce the issue using the linked JSFiddle in Chrome, with the bearing set to 29º. Trace how the bearing option affects the zoom calculation. Done means all 6 stations are visible after clicking “Fit to Line at 29º Bearing,” rather than only 4.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.