diff options
Diffstat (limited to 'src/static')
| -rw-r--r-- | src/static/main.js | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/static/main.js b/src/static/main.js index 405f455..c37c92b 100644 --- a/src/static/main.js +++ b/src/static/main.js @@ -23,11 +23,26 @@ async function fetchChains() { iconAnchor: [8, 8], }); } + fetchAll() +} + - fetchShops(); +function addPolygon(store) { + console.log(store) + let color; + if (store.brand === 'Rema 1000'){ + color = 'blue'; + } else if (store.brand === 'Netto'){ + color = 'yellow' + } + else if (store.brand === 'Coop 365discount'){ + color = 'green'; + }else{ + color = 'red'} + L.polygon(store.polygon, {color: color}).addTo(map); } -function addMarker(shop) { +function addShop(shop) { let icon; if (known_store_chains.includes(shop.brand)){ @@ -40,17 +55,14 @@ function addMarker(shop) { title: shop.name, icon: icon, }).addTo(map); -} - -function addPolygon(polygon) { - L.polygon(polygon, {color: 'red'}).addTo(map); + addPolygon(shop) } -async function fetchShops() { - const response = await fetch("supermarkets.json"); +async function fetchAll() { + const response = await fetch("all.json"); const shops = await response.json(); - shops.forEach((shop) => addMarker(shop)); + shops.forEach((shop) => addShop(shop)); } @@ -70,5 +82,4 @@ map.on('moveend', function() { update() }); -fetchChains() -fetch_voronoi_polygons()
\ No newline at end of file +fetchChains()
\ No newline at end of file |
