Map isn't respecting passed in 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
Latest
### Expected behavior
We are building an application using mapbox where the map bounds can be shared across multiple users. We've found that when passing in a set of bounds to initalize a map, that there are differences across the shared bounding boxes, even though the map is being opened in the same browser, with the same size of map.
### Steps to trigger the unexpected behavior
Using the below code take the console output and replace the bounds with that output, whilst maintaining the same size of map, at that point I'm expecting `map.getBounds()` to return the same as the passed in bounds -
```
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/standard',
bounds: new mapboxgl.LngLatBounds(
{lat: 51.982898278386415, lng: 0.5317321224441969},
{lat: 51.90657505892173, lng: 0.21361845136780744}
),
fitBoundsOptions: { padding: 0 },
padding: 0
});
// This will be different from the passed in bounds...
console.log(map.getBounds());
```
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 Map constructor's bounds and fitBoundsOptions handling, then compare it with the getBounds behavior using the provided reproduction and fixed map dimensions. Done means getBounds() returns the same bounds passed during initialization when padding is zero.
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