feat: fetch data dynamically

This commit is contained in:
uku 2024-10-22 12:02:24 +02:00
parent 256c2eb6bb
commit aea400e306
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
2 changed files with 10 additions and 1390 deletions

View file

@ -1,18 +1,23 @@
<script lang="ts">
import { page } from "$app/stores";
import { onMount } from "svelte";
import type { GeoJSONOptions } from "leaflet";
import "leaflet/dist/leaflet.css";
import lignes from "./lignes";
import { page } from "$app/stores";
const linesUrl =
"https://data.grandlyon.com/geoserver/sytral/ows?SERVICE=WFS&VERSION=2.0.0&request=GetFeature&typename=sytral:tcl_sytral.tcllignemf_2_0_0&outputFormat=application/json&SRSNAME=EPSG:4171&sortBy=gid";
onMount(async () => {
const L = (await import("leaflet")).default;
const res = await fetch(linesUrl);
const lignes: GeoJSON.FeatureCollection = await res.json();
const bbox = lignes.bbox || [0, 0, 0, 0];
const centerLat = (bbox[1] + bbox[3]) / 2;
const centerLon = (bbox[0] + bbox[2]) / 2;
onMount(async () => {
const L = (await import("leaflet")).default;
const map = L.map("map").setView([centerLat, centerLon], 13);
const params = $page.url.searchParams;

File diff suppressed because it is too large Load diff