Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong zoom level or NaN zoom #24

Open
qpavy opened this issue Feb 17, 2020 · 5 comments
Open

Wrong zoom level or NaN zoom #24

qpavy opened this issue Feb 17, 2020 · 5 comments

Comments

@qpavy
Copy link

qpavy commented Feb 17, 2020

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 =>
IcN2PsQ2S

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 =>
jqCt596g

(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 =)

@qpavy
Copy link
Author

qpavy commented Apr 26, 2020

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
buggeoviewport

-> Geoviewport give 3.7 zoom level
buggeoviewport2

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 ?

@ringsaturn
Copy link

Same here.

Wired zoom response break my program.

@qpavy
Copy link
Author

qpavy commented Aug 3, 2020

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].

@vedmant
Copy link

vedmant commented Dec 16, 2020

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

@emmnlala
Copy link

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants