From 4040d03ae6ef8054671fda169d239e4dba810b12 Mon Sep 17 00:00:00 2001 From: philip Date: Sat, 28 Dec 2019 18:09:07 +0000 Subject: [PATCH] Fix problem with zero size canvas drawing --- src/ol/reproj.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ol/reproj.js b/src/ol/reproj.js index e669a4ec82..32ded4f1a5 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -135,12 +135,15 @@ export function render(width, height, pixelRatio, const srcWidth = getWidth(src.extent); const srcHeight = getHeight(src.extent); - stitchContext.drawImage( - src.image, - gutter, gutter, - src.image.width - 2 * gutter, src.image.height - 2 * gutter, - xPos * stitchScale, yPos * stitchScale, - srcWidth * stitchScale, srcHeight * stitchScale); + // This test should never fail -- but it does. Need to find a fix the upstream condition + if (src.image.width > 0 && src.image.height > 0) { + stitchContext.drawImage( + src.image, + gutter, gutter, + src.image.width - 2 * gutter, src.image.height - 2 * gutter, + xPos * stitchScale, yPos * stitchScale, + srcWidth * stitchScale, srcHeight * stitchScale); + } }); const targetTopLeft = getTopLeft(targetExtent);