mapbox / mapbox/mapbox-gl-js

getCenter is not correct after resize the container programatically

Open
#9,082 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**:
v1.5.0

### Question
When the container is resized by css programatically, the center of the map is visually changed. but when we call `getCenter`, it returns previous center of the map. It's the point of breaking consistency until we call `resize`. Cannot just get the center of the literally visible map? or Cannot watch the container size is changing to call `resize` automatically?

### Links to related documentation
https://jsfiddle.net/cs09g/q3x1ohun/17/

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 behavior in the linked JSFiddle using mapbox-gl-js v1.5.0, focusing on the getCenter and resize entry points named in the report. No source file or test is identified, so trace how a programmatic container resize affects the reported center and establish a regression test. Done means the behavior is consistent with the visible map after resizing.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.