feat: fetch data dynamically
This commit is contained in:
parent
256c2eb6bb
commit
aea400e306
2 changed files with 10 additions and 1390 deletions
|
@ -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 bbox = lignes.bbox || [0, 0, 0, 0];
|
||||
const centerLat = (bbox[1] + bbox[3]) / 2;
|
||||
const centerLon = (bbox[0] + bbox[2]) / 2;
|
||||
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;
|
||||
|
||||
const map = L.map("map").setView([centerLat, centerLon], 13);
|
||||
|
||||
const params = $page.url.searchParams;
|
||||
|
|
1385
src/routes/lignes.ts
1385
src/routes/lignes.ts
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue