From 51a273f8de58eac470235b81dfbea8fa4a292a1a Mon Sep 17 00:00:00 2001 From: James Lyne Date: Thu, 31 Dec 2020 22:38:58 +0000 Subject: [PATCH] Fix some timing issues in DynmapIcon --- src/leaflet/icon/DynmapIcon.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/leaflet/icon/DynmapIcon.ts b/src/leaflet/icon/DynmapIcon.ts index bb83ff2..a233fc8 100644 --- a/src/leaflet/icon/DynmapIcon.ts +++ b/src/leaflet/icon/DynmapIcon.ts @@ -93,7 +93,7 @@ export class DynmapIcon extends DivIcon { } update(options: DynmapIconOptions) { - if(options.icon !== this.options.icon) { + if(this._image && options.icon !== this.options.icon) { this._image!.src = `${window.config.url.markers}_markers_/${options.icon}.png`; this.options.icon = options.icon; } @@ -101,13 +101,13 @@ export class DynmapIcon extends DivIcon { const iconSize = point(options.iconSize || [16, 16] as PointExpression), oldSize = point(this.options.iconSize as PointExpression); - if(iconSize.x !== oldSize.x || iconSize.y !== oldSize.y) { + if(this._image && (iconSize.x !== oldSize.x || iconSize.y !== oldSize.y)) { this._image!.width = iconSize.x; this._image!.height = iconSize.y; this.options.iconSize = options.iconSize; } - if(options.label !== this.options.label || options.isHtml !== this.options.isHtml) { + if(this._label && (options.label !== this.options.label || options.isHtml !== this.options.isHtml)) { if (options.isHtml) { this._label!.innerHTML = options.label; } else {