Due to some imperfect CSS, the page I was loading had a map that was 34px wide and 640px tall. I tried calling the following:
map.fitBounds(myBounds, { padding: 20 });
which was blowing up with:
Error: Invalid LngLat object: (NaN, NaN)
I traced that down to the fact that inside fitBounds()
, scaleX
was coming out to -0.02134339601961903. That's because the width is smaller than twice the padding, which you can see here will be a problem: https://github.com/mapbox/mapbox-gl-js/blob/d1e521322da88b81f143190a0b79eab28ca99aaf/js/ui/camera.js#L361
There should probably be some kind of rescue for these calculations with a default value for situations like these.
Hope that's enough info to get by on!
Having the same issue! Any plans to have this one fixed soon?
Thanks for Mapbox GL!
I just added a better warning for this error in #3890 馃樃
Looks like this was addressed sufficiently in #3890.
Most helpful comment
Having the same issue! Any plans to have this one fixed soon?
Thanks for Mapbox GL!