feat: add initial map with lines
This commit is contained in:
parent
45cc451f27
commit
50a12fe432
5 changed files with 1439 additions and 2 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -11,11 +11,15 @@
|
||||||
"lint": "prettier --check . && eslint .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write ."
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"leaflet": "^1.9.4"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "^3.2.5",
|
"@sveltejs/adapter-auto": "^3.2.5",
|
||||||
"@sveltejs/kit": "^2.7.1",
|
"@sveltejs/kit": "^2.7.1",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||||
"@types/eslint": "^9.6.1",
|
"@types/eslint": "^9.6.1",
|
||||||
|
"@types/leaflet": "^1.9.12",
|
||||||
"eslint": "^9.12.0",
|
"eslint": "^9.12.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-svelte": "^2.45.1",
|
"eslint-plugin-svelte": "^2.45.1",
|
||||||
|
|
|
@ -1,2 +1,31 @@
|
||||||
<h1>Welcome to SvelteKit</h1>
|
<script lang="ts">
|
||||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
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: '© <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
1
src/routes/+page.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const ssr = false;
|
1403
src/routes/lignes.json
Normal file
1403
src/routes/lignes.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue