mapbox.js icon indicating copy to clipboard operation
mapbox.js copied to clipboard

Detecting objects with no length in grid.js

Open heaversm opened this issue 9 years ago • 0 comments

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; };

heaversm avatar Dec 12 '15 12:12 heaversm