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.flyTo is throwing a typeError: failed to invert matrix #4753

Closed
keyofj opened this issue May 25, 2017 · 4 comments · Fixed by #4761
Closed

map.flyTo is throwing a typeError: failed to invert matrix #4753

keyofj opened this issue May 25, 2017 · 4 comments · Fixed by #4761

Comments

@keyofj
Copy link

keyofj commented May 25, 2017

mapboxgl.js v.0.37.0
turfjs v4.3.1
Google Chrome 58.0.3029.110 (64-bit)

Code Sample:
var options = {
center: [-82.6078, 39.6964],
zoom: 14
};
map.flyTo(options);

This appears to happen when the map is already at a zoom level greater than what is passed in. In our case, the map was at zoom level 22 from doing a fitbounds previously.

The lng / lat is for a postal carrier route 43130B002.

Uncaught Error: failed to invert matrix
at Transform._calcMatrices (transform.js:507)
at Transform.prototypeAccessors.zoom.set (transform.js:143)
at e. (camera.js:789)
at e. (camera.js:839)
at Object.exports.timed (browser.js:43)
at e._ease (camera.js:838)
at e.flyTo (camera.js:785)
at GeocoderAPI.js:133
at Object. (Utilities.js:23)
at fire (jquery-1.12.3.js:3232)

I saw that a similar error was reported in 2016 when using map.fitBounds() but was fixed and closed.
https://github.com/mapbox/mapbox-gl-js/issues/3474

Additional Information Discovered:
When passing the featureCollection for the above carrier route 43130B002 to the following:

var _fitBounds = function (featureCollection) {
    var map = nmap.map.getMap(); 

    var bbox = turf.bbox(featureCollection);
    map.fitBounds(bbox, { padding: 50 });
}

The map zooms to level 22 to this area on the map. If after this process, I do a flyto() the error above happens. If I zoom back out one tick, and do a flyto() the error does not happen. If I do the flyto() first, the error does not happen.

I set the max zoom level for the map to 21 and repeated the process and it throws the error. when ever a fitBounds is called that zooms to the max level of the map if a flyto() is done afterwards.

@jfirebaugh
Copy link
Contributor

Thanks for reporting, I can replicate this with https://jsfiddle.net/xgn4736f/.

@mollymerp
Copy link
Contributor

bisected to c0dcee7 – working on a fix.

@yangyanan05521
Copy link

Hey,I have the same problem,could you please tell me how to solve this problem?Thanks a lot!!

@mollymerp
Copy link
Contributor

@yangyanan05521 this issue should have been fixed. If you're experiencing an issue with the most recent release please open a new ticket.

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

Successfully merging a pull request may close this issue.

4 participants