From f13b4a9346007819d997ac1cb897cbc95268c7b7 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sat, 17 Nov 2018 21:24:18 -0500 Subject: [PATCH] leaflet: update the paint function. Change-Id: I699a83468b4a240d05ad48467e931f3932d21373 --- loleaflet/src/control/Control.LokDialog.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index 679f0efba..318148c70 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -396,15 +396,17 @@ L.Control.LokDialog = L.Control.extend({ this._onDialogClose(this._currentId, true); }, - _paintDialog: function(dialogId, rectangle, imgData) { - if (!this._isOpen(dialogId)) - return; + _paintDialog: function(parentId, rectangle, imgData) { - var strId = this._toStrId(dialogId); - var img = new Image(); + var strId = this._toStrId(parentId); var canvas = document.getElementById(strId + '-canvas'); + if (!canvas) + return; // no window to paint to + var ctx = canvas.getContext('2d'); + var that = this; + var img = new Image(); img.onload = function() { var x = 0; var y = 0; @@ -417,9 +419,10 @@ L.Control.LokDialog = L.Control.extend({ ctx.drawImage(img, x, y); // if dialog is hidden, show it - var dialogContainer = L.DomUtil.get(strId); - $(dialogContainer).parent().show(); - that.focus(dialogId); + var container = L.DomUtil.get(strId); + if (container) + $(container).parent().show(); + that.focus(parentId); }; img.src = imgData; },