map.fitToBounds() throws Failed to invert matrix error for specific combination of bounds, center & zoom
Environment
Machine: MacBook Pro (Retina, 15-inch, Mid 2015) OS: OSX El Captain 10.11.6 Browser: Chrome 56.0.2924.87 (64-bit) MapboxGl: v0.32.1
mapbox-gl-js 0.32.1:
Steps to Trigger Behavior
https://jsfiddle.net/bewithjonam/0nvLo411/2/
Expected Behavior
To display map within given bounds
Actual Behavior
Map is not displayed properly (no tiles) and got console error.
Uncaught Error: failed to invert matrix
at Transform._calcMatrices (VM8737 mapbox-gl.js:42)
at Transform.resize (VM8737 mapbox-gl.js:42)
at e.resize (VM8737 mapbox-gl.js:211)
at e._onWindowResize (VM8737 mapbox-gl.js:211)
Hi @bewithjonam, Thanks for reporting this issue. This happens when the requested map bounds cannot fit on the canvas at the given zoom, padding, center etc. In your case, the bounds you have in your example represent an area too large to fit in the canvas at those high zoom levels.
We've added a better error message that will ship in the next release so hopefully this wont be as confusing in the future: https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/camera.js#L383-L386