diff options
| author | user <user@node5.net> | 2024-04-06 22:23:06 +0200 |
|---|---|---|
| committer | user <user@node5.net> | 2024-04-06 22:23:06 +0200 |
| commit | fa360829bfe3f04f3e6d9af196dc9fd480864d4b (patch) | |
| tree | df04f3a39133d9edb0a46d591d23354849154c67 /src/static/main.js | |
initial commit - displays voronoi diagram
Diffstat (limited to 'src/static/main.js')
| -rw-r--r-- | src/static/main.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/static/main.js b/src/static/main.js new file mode 100644 index 0000000..24d0edf --- /dev/null +++ b/src/static/main.js @@ -0,0 +1,32 @@ +var map = L.map('map').setView([55.68, 12.57], 13); +L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, + attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' +}).addTo(map); + + +function addMarker(shop) { + L.marker([shop.lat, shop.long], {title: shop.name, }).addTo(map); +} + +function addPolygon(polygon) { + L.polygon(polygon, {color: 'red'}).addTo(map); + + console.log(polygon.coordinates) +} + + +async function fetchShops() { + const response = await fetch("supermarkets.json"); + const shops = await response.json(); + shops.forEach((shop) => addMarker(shop)); +} + +fetchShops() + +async function fetch_voronoi_polygons() { + const response = await fetch("voronoi_polygons.json"); + const voronoi_polygons = await response.json(); + voronoi_polygons.forEach((polygon) => addPolygon(polygon)); +} +fetch_voronoi_polygons()
\ No newline at end of file |
