Avoid uncaught exception 'Error: Image given has not completed loading' while drawing with canvas
This commit is contained in:
parent
2f97d7fda0
commit
0edffef74b
@ -250,7 +250,15 @@ var CartoDatasource = require('./datasource');
|
||||
var frame = layer.frames()[fr];
|
||||
var fr_sprites = sprites[frame] || (sprites[frame] = []);
|
||||
for (var k = 0, len = keys.length; k < len; k++) {
|
||||
this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer);
|
||||
try {
|
||||
this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer);
|
||||
} catch (error) {
|
||||
if (callback) {
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,7 +346,7 @@ var CartoDatasource = require('./datasource');
|
||||
if (sp) {
|
||||
var x = tile.x[posIdx]- (sp.width >> 1) + anchor;
|
||||
var y = tileMax - tile.y[posIdx] + anchor; // flip mercator
|
||||
ctx.drawImage(sp, x, y - (sp.height >> 1));
|
||||
ctx.drawImage(sp, x, y - (sp.height >> 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user