From 1d7dfe72c2467fc00d5bd42ffaf832d2c4c0112e Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 1 Oct 2024 11:04:42 +0200 Subject: [PATCH] set map icons when map is loaded --- web/themes/custom/caravane/assets/js/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/caravane/assets/js/main.js b/web/themes/custom/caravane/assets/js/main.js index f209ff8..ca7731f 100644 --- a/web/themes/custom/caravane/assets/js/main.js +++ b/web/themes/custom/caravane/assets/js/main.js @@ -146,13 +146,17 @@ import router from './router/router'; } function setupEtapeMapPopup(store) { - setTimeout(() => { + jQuery(document).bind('leaflet.map', function(event, map, lMap) { + + //setTimeout(() => { const icons = document.querySelectorAll('.leaflet-map-divicon'); for (let icon of icons) { const colorContainer = icon.querySelector('.couleur'); const colorDiv = colorContainer.querySelector('div > div:nth-of-type(4)'); const color = colorDiv.innerText.substring(colorDiv.innerText.indexOf('>') + 1, colorDiv.innerText.indexOf('<', colorDiv.innerText.indexOf('>') + 1)).trim(); + console.log(color); + const nid = icon.querySelector('.nid'); const nidValue = nid.querySelector('div > div').innerText; @@ -178,7 +182,8 @@ import router from './router/router'; icon.style.transform = icon.style.transform.split(' ')[0] + icon.style.transform.split(' ')[1] + icon.style.transform.split(' ')[2]; }) } - }, 500); + // }, 500); + }); } init()