feat: center map on bounding box
This commit is contained in:
parent
71e0ad89a1
commit
2f1e0ba787
1 changed files with 4 additions and 1 deletions
|
@ -4,10 +4,13 @@
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import lignes from './lignes.json';
|
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 () => {
|
onMount(async () => {
|
||||||
const L = (await import('leaflet')).default;
|
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', {
|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue