mapbox.js
mapbox.js copied to clipboard
Detecting objects with no length in grid.js
I had a recurring javascript error originating from grid.js line 12 (of the bower uncompressed downloads)
Uncaught type error, cannot read property [20] of Undefined
any time I moved the mouse over my map - which is this line:
var idx = utfDecode(data.grid[y].charCodeAt(x)),
The line above is:
if (!data) return;
but in my case, there is a data object, but it is empty: (data = {};) so a check for no object length would resolve this error:
var isEmpty = Object.keys(data);
if (isEmpty){ return; };