diff --git a/src/canvas/quadFeature.js b/src/canvas/quadFeature.js index 37fd20e89e..fa8c07e522 100644 --- a/src/canvas/quadFeature.js +++ b/src/canvas/quadFeature.js @@ -174,8 +174,11 @@ var canvas_quadFeature = function (arg) { if (!quad.crop) { context2d.drawImage(src, 0, 0); } else { - context2d.drawImage(src, 0, 0, quad.crop.x, quad.crop.y, 0, 0, - quad.crop.x, quad.crop.y); + var cropx = Math.min(src.w, quad.crop.x), + cropy = Math.min(src.h, quad.crop.y); + if (cropx > 0 && cropy > 0) { + context2d.drawImage(src, 0, 0, cropx, cropy, 0, 0, cropx, cropy); + } } }); });