feat: add initial map with lines

This commit is contained in:
uku 2024-10-18 12:54:26 +02:00
parent 45cc451f27
commit 50a12fe432
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
5 changed files with 1439 additions and 2 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -11,11 +11,15 @@
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"dependencies": {
"leaflet": "^1.9.4"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.5",
"@sveltejs/kit": "^2.7.1",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@types/eslint": "^9.6.1",
"@types/leaflet": "^1.9.12",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.45.1",

View file

@ -1,2 +1,31 @@
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<script lang="ts">
import 'leaflet/dist/leaflet.css';
import lignes from './lignes.json';
import L from 'leaflet';
function createMap(node: HTMLElement) {
const map = L.map(node).setView([45.76, 4.832], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
lignes.features.forEach((feature) => {
const color = 'rgb(' + feature.properties.couleur.replaceAll(' ', ',') + ')';
// @ts-ignore
L.geoJSON(feature, { style: { color } }).addTo(map);
});
}
</script>
<div class="map" use:createMap></div>
<style>
.map {
height: 800px;
width: 100%;
}
</style>

1
src/routes/+page.ts Normal file
View file

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

1403
src/routes/lignes.json Normal file

File diff suppressed because it is too large Load diff