From 6f53cb21280f86a179cdc08261ffa7de4ec72453 Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 25 Feb 2026 20:27:11 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/index.html b/index.html index 9b59a52..932fc48 100644 --- a/index.html +++ b/index.html @@ -266,32 +266,6 @@ setInterval(() => fetchWorkerLocation(serviceId), 10000); } - // ========================================== - // LÓGICA DE MAPA EN TIEMPO REAL (CORREGIDA) - // ========================================== - function initLiveMap(serviceId) { - // CORRECCIÓN: El ID correcto es liveMap- (no map-) - if(!document.getElementById(`liveMap-${serviceId}`)) return; - - // 1. Configuramos el mapa de Leaflet - liveMaps[serviceId] = L.map(`liveMap-${serviceId}`, { zoomControl: false, attributionControl: false }).setView([40.416775, -3.703790], 6); - L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png').addTo(liveMaps[serviceId]); - - // 2. Creamos un icono HTML personalizado (un puntito azul que brilla) - const carIcon = L.divIcon({ - className: 'custom-div-icon', - html: `
`, - iconSize: [20, 20], - iconAnchor: [10, 10] - }); - - liveMarkers[serviceId] = L.marker([40.416775, -3.703790], {icon: carIcon}); - - // 3. Ejecutamos la búsqueda de coordenadas cada 10 segundos - fetchWorkerLocation(serviceId); - setInterval(() => fetchWorkerLocation(serviceId), 10000); - } - async function fetchWorkerLocation(serviceId) { try { const res = await fetch(`${API_URL}/public/portal/${urlToken}/location/${serviceId}`); @@ -299,7 +273,7 @@ if (data.ok && data.location) { const loader = document.getElementById(`map-loader-${serviceId}`); - if(loader) loader.classList.add('hidden'); // Ocultar pantalla de carga + if(loader) loader.classList.add('hidden'); // Ocultar pantalla de "Buscando satélites" const lat = parseFloat(data.location.lat); const lng = parseFloat(data.location.lng); @@ -313,10 +287,6 @@ liveMarkers[serviceId].setLatLng([lat, lng]); liveMaps[serviceId].flyTo([lat, lng], 16, { animate: true, duration: 1.5 }); } - } else { - // Si el técnico aún no ha mandado su ubicación, avisamos al cliente - const p = document.querySelector(`#map-loader-${serviceId} p`); - if(p) p.innerText = "ESPERANDO SEÑAL GPS DEL TÉCNICO..."; } } catch(e) {} }