Wrong zoom level or NaN zoom
Opened this issue · 5 comments
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 }
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 =)
Hello,
I still facing the same issue and still don't know how to resolve it.
I tried to change dimension parameter to a square of 1280 / 1280 but i still have wrong zoom level or NaN.
Here an example of a wrong zoom level:
-> correct zoom between San Francisco and Paris should be around 2.6 with mapbox static image playground
-> Geoviewport give 3.7 zoom level
And you can test incorrect zoom level and NaN zoom here:
https://stackblitz.com/edit/typescript-k6nwhg
I am really confuse !
Is anyone have ever encountered this issue ?
Same here.
Wired zoom
response break my program.
Check a second time the coordinates array you use as first argument of geoViewport.viewport.
They should be [West,South,East,North] or [minimum longitude, minimum latitude, maximum longitude, maximum latitude].
I have also this problem, but it appears only for some specific boundaries, for example:
[-112.16601, 37.622623, -112.082016, 37.672085]
gives me wrong zoom 13, while actual zoom should be around 12
I had this issue solved by adding 360 to east longitude if its smaller than west longitude
[southWest.longitude,
southWest.latitude,
northEast.longitude < southWest.longitude ? northEast.longitude + 360 : northEast.longitude,
northEast.latitude]