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

Better error when providing NaN/null camera settings #1189

Closed
tmcw opened this issue Apr 28, 2015 · 12 comments
Closed

Better error when providing NaN/null camera settings #1189

tmcw opened this issue Apr 28, 2015 · 12 comments
Assignees

Comments

@tmcw
Copy link
Contributor

tmcw commented Apr 28, 2015

2015-04-28 at 1 53 pm

cause is in getProjTransform: https://github.com/mapbox/mapbox-gl-js/blob/master/js/geo/transform.js#L336-L357 which is returning an array of NaNs.

@ansis
Copy link
Contributor

ansis commented Apr 28, 2015

map.transform:

{"tileSize":512,"_minZoom":0,"_maxZoom":20,"latRange":[-85.05113,85.05113],"width":407,"height":701,"_zoom":11.237981760650836,"scale":2415.2917653027107,"tileZoom":11,"zoomFraction":0.2379817606508361,"center":{"lat":37.76860424585354,"lng":-122.40030284531892},"angle":0,"_altitude":1.5,"_pitch":0}
{"tileSize":512,"_minZoom":0,"_maxZoom":20,"latRange":[-85.05113,85.05113],"width":1011,"height":353,"_zoom":0,"scale":1,"tileZoom":0,"zoomFraction":0,"center":{"lat":0,"lng":0},"angle":0,"_altitude":1.5,"_pitch":null}

@tmcw
Copy link
Contributor Author

tmcw commented Apr 28, 2015

The result I got was because the app was calling setView without a pitch argument which is now required in master: issue for that is #1051

@tmcw
Copy link
Contributor Author

tmcw commented Apr 28, 2015

This is still triggerable without misusing the API like I was doing: just use shift-drag zooming in the /debug page.

@ansis ansis closed this as completed in 81c7fb1 Apr 28, 2015
@eatpurely
Copy link

I am getting this again in 0.23.0 when ever i do fitBounds().

https://gist.github.com/eatpurely/d7e8cd8e76695472d87d828fc60645a4

@mariotacke
Copy link

Same here :/

@ansis
Copy link
Contributor

ansis commented Sep 6, 2016

@eatpurely what are the values of addressLocation and driverLocation that result in an error?

@ansis ansis reopened this Sep 6, 2016
@lucaswoj
Copy link
Contributor

lucaswoj commented Sep 6, 2016

@ansis These errors are almost certainly related to #2414.

tuttinator referenced this issue in nzherald/ember-cli-mapbox-gl Sep 12, 2016
@mourner
Copy link
Member

mourner commented Sep 12, 2016

Comment from the commit above:

It turns out that a null bearing is the cause of the 'Failed to invert matrix' error, rather than the format or order of latitude and longitude coordinates: #1189

@mourner mourner self-assigned this Sep 12, 2016
@mourner mourner changed the title "failed to invert matrix" in Transform Better error when providing NaN/null camera settings Sep 12, 2016
@stuyam
Copy link

stuyam commented Oct 13, 2016

I was getting this error too from the fitBounds() method, however I later realized I had just a few values switched so it was not able to make a proper box and got messed up. I wish that the method could accept an object with {ne: {lon: 0, lat: 0}, sw: {lon: 0, lat:0}} so you don't have to know the order that the lat and lons should be placed in an array, more explicit when they are named.

@daschi
Copy link

daschi commented Nov 18, 2016

We're seeing the failed to invert matrix error when a user navigates to a map that renders 2 or more markers that have the exact same LngLat. We see it's because fitBounds does not have two different points to draw a box, but we were wondering if there is a method in the API to easily check whether the bounds are equal, and to only perform fitBounds if they are not equal. For now we are using this:

if(!(bounds._ne.lat === bounds._sw.lat && bounds._ne.lng === bounds._sw.lng)){ map.fitBounds(bounds) }

@mollymerp
Copy link
Contributor

mollymerp commented Nov 22, 2016

@daschi unfortunately we don't have a check like you're describing built into the API. Fortunately, this should be fixed when #3683 merges.

@stuyam fitBounds at a single point is included in #3683 as well.

@lucaswoj
Copy link
Contributor

This error is much much rarer now 😄

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

No branches or pull requests

9 participants