fix: add back ssr

This commit is contained in:
uku 2024-10-21 00:22:09 +02:00
parent 10964ec587
commit 71e0ad89a1
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
2 changed files with 8 additions and 7 deletions

View file

@ -1,11 +1,13 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte';
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
import lignes from './lignes.json'; import lignes from './lignes.json';
import L from 'leaflet'; onMount(async () => {
const L = (await import('leaflet')).default;
function createMap(node: HTMLElement) { const map = L.map('map').setView([45.76, 4.832], 13);
const map = L.map(node).setView([45.76, 4.832], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
@ -18,13 +20,13 @@
// @ts-ignore // @ts-ignore
L.geoJSON(feature, { style: { color } }).addTo(map); L.geoJSON(feature, { style: { color } }).addTo(map);
}); });
} });
</script> </script>
<div class="map" use:createMap></div> <div id="map"></div>
<style> <style>
.map { #map {
height: 100vh; height: 100vh;
width: 100%; width: 100%;
} }

View file

@ -1 +0,0 @@
export const ssr = false;