Mapbox-gl-js: fitBounds with -90 results in uncaught error

Created on 3 Jul 2018  路  1Comment  路  Source: mapbox/mapbox-gl-js

This must have been introduced in a recent version but calling fitBounds with a bounding box containing -90 results in an uncaught error.

screen shot 2018-07-03 at 9 37 20 am

mapbox-gl-js version:
v0.46.0

browser:
Chrome Version 67.0.3396.99 (Official Build) (64-bit)

Steps to Trigger Behavior

Call fitBounds with a sw latitude coordinate of -90

Link to Demonstration

https://jsfiddle.net/tristen/bytzwu08/ Click "Fit bounds" and view the console

bug

Most helpful comment

Hi @tristen, thanks for the great report! This isn't a bug _per se_, but rather an inherent limitation of the Mercator map projection. Mercator maps project the poles at infinity making it impossible to fully render them (both on the web and on paper). Specifically, the Web Mercator projection that Mapbox uses is unable to accurately project latitudes north of 85.05掳 and south of -85.05掳.

I think your report points to a couple of improvements that we can implement however. One is to clamp latitude inputs to the supported range and another is to log a warning to the console alerting the user that this is being done. I'm going to leave this open for now so we can use the ticket to track those improvements.

>All comments

Hi @tristen, thanks for the great report! This isn't a bug _per se_, but rather an inherent limitation of the Mercator map projection. Mercator maps project the poles at infinity making it impossible to fully render them (both on the web and on paper). Specifically, the Web Mercator projection that Mapbox uses is unable to accurately project latitudes north of 85.05掳 and south of -85.05掳.

I think your report points to a couple of improvements that we can implement however. One is to clamp latitude inputs to the supported range and another is to log a warning to the console alerting the user that this is being done. I'm going to leave this open for now so we can use the ticket to track those improvements.

Was this page helpful?
0 / 5 - 0 ratings