From d2c431760fe627803f742d25398f190ec0d7fb32 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 15 Jul 2023 19:41:57 -0600 Subject: [PATCH] remove retry on resizeMarkers, as it caused move events to become mangled --- static/map.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/static/map.js b/static/map.js index d8296e0..b8e3117 100644 --- a/static/map.js +++ b/static/map.js @@ -24,11 +24,11 @@ function initializeMap(mapImgUrl) { // this works but assumes the map is square (reasonable limitation I think) function resizeMarkers() { - let tryAgain = false; + + // for newly created tokens, the icon may not be loaded and thus the resize will not properly complete + // we need a way to queue the resize for when the icon is finished loading + tokens.forEach(t=>{ - if (t.m._icon == null) { - tryAgain = true; - } else { const icon = t.m.options.icon; const scaleFactor = mapImg._image.clientWidth / mapImg._image.naturalWidth; @@ -39,9 +39,7 @@ function resizeMarkers() { t.m.setIcon(icon); } }); - if (tryAgain) { - setTimeout(resizeMarkers, 500) - } + } function processTokens(tokenChanges) {