Fitting map to bounds with large padding - Uncaught Error: Invalid LngLat object: (NaN, -90)
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**: v1.3.1
**browser**: Google Chrome (MacOS) v76.0.3809.132
### Steps to Trigger Behavior
1. Initialise the map and set the map container width and height to something small, e.g. 529px by 400px.
2. Create a lat long bounds instance, using any number of coords
3. Call the fitBounds method, using large padding values
4. View the console
### Link to Demonstration
https://jsfiddle.net/benstaker/thawmsjd/
### Expected Behavior
Map centers to supplied bounds.
### Actual Behavior
The following error outputs in the console:
lng_lat.js:30 Uncaught Error: Invalid LngLat object: (NaN, -90)
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 fitBounds call and the linked JSFiddle, using the reported 529px by 400px container and large padding to reproduce the NaN LngLat error in Chrome. Trace how the supplied bounds and padding produce the invalid longitude, then verify that the map centers on the bounds without a console error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100