fitBounds doesn't work sometimes
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**:1.13.1
### Question
hello,I use addLayer to show some polygons,when change the polygon data,I want to use fitBounds to get better view,most time,it worked well,but sometimes,some area is out of bounds,I don't know why.Am i doing something wrong, or is there a bug in fitbounds?Here is my code:
this.map = new mapboxgl.Map(
{
container:'map',
style:...some style,
zoom:6,
pitch:60,
bearing:0,
center:[113.45,34,81],
hash :false,
renderWorldCopies:false
}
)
when change the data,I use fitBounds, here is the code
let bbox = turf.bbox(mapData)
this.map.fitBounds([[bbox[0],bbox[1]],[bbox[2],bbox[3]]])
looking forward to your reply,thank you.
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 with the reported entry points: addLayer, turf.bbox(mapData), and map.fitBounds after polygon data changes. Reproduce the intermittent out-of-bounds view and inspect the fitBounds API behavior around data or rendering timing; done means identifying a reliable cause or a minimal reproduction that confirms a library bug.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100