@@ -42,8 +42,8 @@
layerTree={basemapTree}
name="basemaps"
onValueChange={(id) => {
- if (map) {
- map.setStyle(basemaps[id]);
+ if ($map) {
+ $map.setStyle(basemaps[id]);
}
}}
/>
@@ -55,12 +55,12 @@
name="overlays"
multiple={true}
onValueChange={(id, checked) => {
- if (map) {
+ if ($map) {
if (checked) {
- if (!map.getSource(id)) {
- map.addSource(id, overlays[id]);
+ if (!$map.getSource(id)) {
+ $map.addSource(id, overlays[id]);
}
- map.addLayer({
+ $map.addLayer({
id,
type: overlays[id].type === 'raster' ? 'raster' : 'line',
source: id,
@@ -73,7 +73,7 @@
}
});
} else {
- map.removeLayer(id);
+ $map.removeLayer(id);
}
}
}}
diff --git a/website/src/lib/stores.ts b/website/src/lib/stores.ts
new file mode 100644
index 00000000..9b168917
--- /dev/null
+++ b/website/src/lib/stores.ts
@@ -0,0 +1,5 @@
+import { writable } from 'svelte/store';
+
+import mapboxgl from 'mapbox-gl';
+
+export const map = writable
(null);
\ No newline at end of file
diff --git a/website/src/routes/+page.svelte b/website/src/routes/+page.svelte
index 7a262867..09dee7d7 100644
--- a/website/src/routes/+page.svelte
+++ b/website/src/routes/+page.svelte
@@ -1,22 +1,18 @@