diff options
| author | user <user@node5.net> | 2024-04-07 18:08:45 +0200 |
|---|---|---|
| committer | user <user@node5.net> | 2024-04-07 18:08:45 +0200 |
| commit | 775409f83d77eb4f98fbcac9419b99721f5c7815 (patch) | |
| tree | 332cddcd0100ef27aa6971a35ddd8029678f9077 /src/static | |
| parent | 21dd4d87554a8222bb84acdc7d22927923c60094 (diff) | |
derive colors from database, verify icons are in sync
Diffstat (limited to 'src/static')
| -rw-r--r-- | src/static/main.js | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/static/main.js b/src/static/main.js index c37c92b..82d474e 100644 --- a/src/static/main.js +++ b/src/static/main.js @@ -10,14 +10,12 @@ let icons = {}; async function fetchChains() { const response = await fetch("chains"); known_store_chains = await response.json(); - icons["Unknown"] = L.icon({ iconUrl: 'icons/Unknown.png', iconSize: [10, 16], iconAnchor: [16, 16], }); - - for (let known_store_chain of known_store_chains) { + for (let known_store_chain in known_store_chains) { icons[known_store_chain] = L.icon({ iconUrl: `icons/${known_store_chain}.png`, iconAnchor: [8, 8], @@ -28,24 +26,19 @@ async function fetchChains() { function addPolygon(store) { - console.log(store) let color; - if (store.brand === 'Rema 1000'){ - color = 'blue'; - } else if (store.brand === 'Netto'){ - color = 'yellow' + if (known_store_chains.hasOwnProperty(store.brand)) { + color = known_store_chains[store.brand]; + } else { + color = 'grey'; } - else if (store.brand === 'Coop 365discount'){ - color = 'green'; - }else{ - color = 'red'} L.polygon(store.polygon, {color: color}).addTo(map); } function addShop(shop) { let icon; - if (known_store_chains.includes(shop.brand)){ + if (known_store_chains.hasOwnProperty(shop.brand)){ icon = icons[shop.brand]; } else { icon = icons["Unknown"]; |
