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

map.getBounds does not account for horizon visibility and low zoom #10261

Closed
arindam1993 opened this issue Jan 6, 2021 · 4 comments · Fixed by #10909
Closed

map.getBounds does not account for horizon visibility and low zoom #10261

arindam1993 opened this issue Jan 6, 2021 · 4 comments · Fixed by #10909
Assignees

Comments

@arindam1993
Copy link
Contributor

mapbox-gl-js version: 2.0.1, 2.0.0

browser: All

Steps to Trigger Behavior

  1. Call map.getBounds at low zoom
  2. Invalid LatLng objects are returned

Link to Demonstration

https://jsfiddle.net/c3hyfme0/2/

@rreusser
Copy link
Contributor

rreusser commented Mar 10, 2021

This is not the same issue, but is maybe closely related enough that it would make sense to investigate at the same time: #10447

@SnailBones SnailBones self-assigned this Jun 29, 2021
@SnailBones SnailBones linked a pull request Jul 27, 2021 that will close this issue
5 tasks
@rreusser
Copy link
Contributor

rreusser commented Jul 27, 2021

The above jsdfiddle is pinned to 2.0.1, but I'm not able to reproduce the specified behavior. I see:

{
  _ne: {
    lat: 89.99998979458857,
    lng: 1052.6131744340337
  },
  _sw: {
    lat: -89.9792927518562,
    lng: -140.77483253940437
  }
}

which, though not clipped to [-90, 90] x [-180, 180], is not invalid. If I zoom out all the way, I get:

{
  _ne: {
    lat: 90,
    lng: 13132.517765333585
  },
  _sw: {
    lat: -90,
    lng: -348.6930098987299
  }
}

I expected "invalid" to mean NaN values, but I just see numbers which reflect the wrapping going on. IMO this might be the preferred behavior since it's easy enough to mod 360 (or more precisely, ((lng + 180) % 360) - 180)) if you want the wrapped values.

@rreusser
Copy link
Contributor

@arindam1993, do you by chance recall any additional context regarding this behavior? Was it returning NaN? Perhaps the window aspect ratio affects the result?

@SnailBones
Copy link
Contributor

SnailBones commented Jul 27, 2021

I think we really have two separate issues here. One is the unbounded longitude values, which as you mention might not be a serious problem.

What's unexpected about those values in this particular case (with high pitch) is that the values don't seem intuitively in line with he horizon. Longitude values from -140 to 1053 (wrapping the Earth ~3 times) are strange when the map appears to display just North America and a few pixels of Africa. I'd expect 180 degrees of longitude spread and we're seeing almost 7 times that.
image
I believe this is the issue with horizon visibility that @arindam mentions in the title.

Another related issue is #10610, though this one seems to be about actual failing values like (NaN, NaN) rather than just unexpectedly large ones.

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