mapbox / mapbox/mapbox-gl-js

map.fitBounds() moves to wrong area with Albers (and other) projections

Open
#12,565 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**: Fails with v2.12.x, v2.11.x, v2.13.0-beta.1

**browser**: Tested with Chrome and Firefox

### Steps to Trigger Behavior

1. Run the demo
2. Add your Mapbox token at line 14.
3. Click the link to "Fit Bounds"
4. See the map move to an extreme corner of the map

### Link to Demonstration

https://jsbin.com/cidiyum/edit?html,output
NOTE: You'll need to add a Mapbox token at line 14.

### Expected Behavior

Should zoom to an area around Corvallis, Oregon.

### Actual Behavior

Zooms to an extreme Northerly corner of the map.

### Additional Notes

Works as expected in versions v2.9.x and 2.10.x. Other specified projections zoom in to different areas (tested with `lambertConformalConic`, `equirectangular`, and `naturalEarth`).

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 running the linked JSBin reproduction with a Mapbox token and compare the affected projection behavior across the listed versions. Investigate the map.fitBounds() path used by Albers and the other named projections; done means fitting bounds centers and zooms near Corvallis, Oregon rather than an extreme map corner.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.