feat: center map on bounding box

This commit is contained in:
uku 2024-10-21 00:26:12 +02:00
parent 71e0ad89a1
commit 2f1e0ba787
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o

View file

@ -4,10 +4,13 @@
import 'leaflet/dist/leaflet.css';
import lignes from './lignes.json';
const centerLat = (lignes.bbox[1] + lignes.bbox[3]) / 2;
const centerLon = (lignes.bbox[0] + lignes.bbox[2]) / 2;
onMount(async () => {
const L = (await import('leaflet')).default;
const map = L.map('map').setView([45.76, 4.832], 13);
const map = L.map('map').setView([centerLat, centerLon], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,