diff options
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"]; |
