Fix some timing issues in DynmapIcon

This commit is contained in:
James Lyne 2020-12-31 22:38:58 +00:00
parent 7dfaf76501
commit 51a273f8de

View File

@ -93,7 +93,7 @@ export class DynmapIcon extends DivIcon {
} }
update(options: DynmapIconOptions) { 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._image!.src = `${window.config.url.markers}_markers_/${options.icon}.png`;
this.options.icon = options.icon; this.options.icon = options.icon;
} }
@ -101,13 +101,13 @@ export class DynmapIcon extends DivIcon {
const iconSize = point(options.iconSize || [16, 16] as PointExpression), const iconSize = point(options.iconSize || [16, 16] as PointExpression),
oldSize = point(this.options.iconSize 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!.width = iconSize.x;
this._image!.height = iconSize.y; this._image!.height = iconSize.y;
this.options.iconSize = options.iconSize; 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) { if (options.isHtml) {
this._label!.innerHTML = options.label; this._label!.innerHTML = options.label;
} else { } else {