diff options
| author | user <user@node5.net> | 2024-04-07 23:10:05 +0200 |
|---|---|---|
| committer | user <user@node5.net> | 2024-04-07 23:10:05 +0200 |
| commit | 0d1ba0fc1bc2c64c7aaaf71f98fd96f35b8b1bab (patch) | |
| tree | 60f40e6546332024d7ee32403e63edb00fd5756d /src/static | |
| parent | 8b16fb83788a04e806573ae3f80e28156a99f27b (diff) | |
add store heatmap
Diffstat (limited to 'src/static')
| -rw-r--r-- | src/static/index.html | 1 | ||||
| -rw-r--r-- | src/static/main.js | 18 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/static/index.html b/src/static/index.html index 115bc76..5bfcc1f 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -9,6 +9,7 @@ <link rel="stylesheet" href="main.css"/> <!-- Make sure you put this AFTER Leaflet's CSS --> <script src="leaflet.js" defer></script> + <script src="leaflet-heat.js" defer></script> <script src="main.js" defer></script> </head> <body> diff --git a/src/static/main.js b/src/static/main.js index 26ba90b..27fa2eb 100644 --- a/src/static/main.js +++ b/src/static/main.js @@ -8,9 +8,13 @@ let known_store_chains; let icons = {}; var markers = L.featureGroup().addTo(map); +var polygons = L.featureGroup().addTo(map); +var heatmap = L.featureGroup().addTo(map); var overlayMaps = { - "Icons": markers + "Icons": markers, + "Polygons": polygons, + "Heatmap": heatmap }; var layerControl = L.control.layers({},overlayMaps).addTo(map); @@ -40,7 +44,7 @@ function addPolygon(store) { } else { color = 'grey'; } - L.polygon(store.polygon, {color: color}).addTo(map); + L.polygon(store.polygon, {color: color}).addTo(polygons); } function addShop(shop) { @@ -66,6 +70,12 @@ async function fetchAll() { shops.forEach((shop) => addShop(shop)); } +async function fetchShopHeatmap() { + const response = await fetch("stores.json"); + const shops = await response.json(); + var heat = L.heatLayer(shops, {radius: 30}).addTo(heatmap); +} + async function fetch_voronoi_polygons() { const response = await fetch("voronoi_polygons.json"); @@ -83,4 +93,6 @@ map.on('moveend', function() { update() }); -fetchChains()
\ No newline at end of file +fetchChains() + +fetchShopHeatmap(); |
