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;