Wrong zoom level or NaN zoom
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 197
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I am using this library to generate multiple mapbox static map with differents bounds.
I have 4 generated maps and 3 of them have incorrect zoom:
the good one :
const viewport = geoViewport.viewport([40.7127281,-74.0060152,48.862725,2.287592],[877,1240],0,20,512);
// { center: [ 44.78772655, -35.859211599999995 ], zoom: 2 }
result =>

One of the 4 generated maps gives me a wrong zoom level :
const viewport = geoViewport.viewport([36.1672559,-122.419,48.862725,2.287592],[877,1240],0,20,512);
// { center: [ 42.51499045, -60.065704 ], zoom: 3 }
I should have bounds between San-Francisco and Paris but it gives me this =>

(The center coordinates are good but zoom level isn't)
And the 2 others viewport gives me "NaN" zoom:
const viewport = geoViewport.viewport([36.1672559,-122.419,37.7793,-115.1485163],[877,1240],0,20,512);
// { center: [ 36.973277949999996, -118.78375815 ], zoom: NaN }
and
const viewport = geoViewport.viewport([37.7793,-122.419,40.7127281,-74.0060152],[877,1240],0,20,512);
// { center: [ 39.24601405, -98.2125076 ], zoom: NaN }
I always use the same function in my code and WSEN array of bounds is always respected.
I am a little confused about what happened here =/
Did I missed something?
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 at the geoViewport.viewport entry point and reproduce the three bounds examples with the stated dimensions, zoom limits, and tile size. Compare the returned center and zoom values, then verify that the San Francisco–Paris cases produce a finite zoom that fits both bounds and the expected map extent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100