diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 16:46:15 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 16:46:15 -0700 |
commit | 230b5b53460982ef888d309725f027ea29b29bb6 (patch) | |
tree | f5aca22f65c534e110ca017039b2f341f60c7df7 /modern/src/map/Map.js | |
parent | 75e62d6f56bffb8d4fd18ce7d2d9077821095c85 (diff) | |
download | etbsa-traccar-web-230b5b53460982ef888d309725f027ea29b29bb6.tar.gz etbsa-traccar-web-230b5b53460982ef888d309725f027ea29b29bb6.tar.bz2 etbsa-traccar-web-230b5b53460982ef888d309725f027ea29b29bb6.zip |
Fix map switches
Diffstat (limited to 'modern/src/map/Map.js')
-rw-r--r-- | modern/src/map/Map.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index c2861ed..3afa48d 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -40,21 +40,23 @@ const updateReadyValue = (value) => { const initMap = async () => { if (ready) return; - const background = await loadImage('images/background.svg'); - map.addImage('background', await prepareIcon(background), { - pixelRatio: window.devicePixelRatio, - }); - await Promise.all(deviceCategories.map(async (category) => { - const results = []; - ['green', 'red', 'gray'].forEach((color) => { - results.push(loadImage(`images/icon/${category}.svg`).then((icon) => { - map.addImage(`${category}-${color}`, prepareIcon(background, icon, palette.common[color]), { - pixelRatio: window.devicePixelRatio, - }); - })); + if (!map.hasImage('background')) { + const background = await loadImage('images/background.svg'); + map.addImage('background', await prepareIcon(background), { + pixelRatio: window.devicePixelRatio, }); - await Promise.all(results); - })); + await Promise.all(deviceCategories.map(async (category) => { + const results = []; + ['green', 'red', 'gray'].forEach((color) => { + results.push(loadImage(`images/icon/${category}.svg`).then((icon) => { + map.addImage(`${category}-${color}`, prepareIcon(background, icon, palette.common[color]), { + pixelRatio: window.devicePixelRatio, + }); + })); + }); + await Promise.all(results); + })); + } updateReadyValue(true); }; |