From 08ce21218ecd18b2f9f6465e8cebbf4cbec85365 Mon Sep 17 00:00:00 2001 From: Francisco Sandoval Date: Sat, 2 Mar 2024 18:10:40 -0300 Subject: [PATCH] cambios sabado 2 de marzo 2024 --- src/pages/mapas/Rutas.svelte | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/mapas/Rutas.svelte b/src/pages/mapas/Rutas.svelte index 56bba4d..9cd3022 100644 --- a/src/pages/mapas/Rutas.svelte +++ b/src/pages/mapas/Rutas.svelte @@ -85,8 +85,12 @@ } if (!myMap) { myMap = L.map(elMap) - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - { attribution: '© OpenStreetMap contributors' } + L.tileLayer( + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + { + maxZoom: 19, + attribution: '© OpenStreetMap contributors' + } ).addTo(myMap); } @@ -114,7 +118,11 @@ const coordenadas = data.positions.map(({ shape_pt_lat, shape_pt_lon}) => [shape_pt_lat, shape_pt_lon]) polyline = L.polyline(coordenadas, { color: 'red' }).addTo(myMap) - myMap.fitBounds(polyline.getBounds()); + + const bound = polyline.getBounds() + if (bound._northEast && bound._southWset) { + myMap.fitBounds(polyline.getBounds()); + } if (coordenadas) { marker1 = L.marker(coordenadas[0], { icon: iconPartida }).addTo(myMap) @@ -124,6 +132,7 @@ } } catch (error) { + console.log({ error }) globalThis.toast.error(error) } finally { loading = false;