Perf/Fix: Resolve Google Maps OverQuotaMapError through marker recycling and instance reuse

This commit is contained in:
2026-03-03 15:40:13 -05:00
parent df0a4397f6
commit 7ff205b12a
2 changed files with 16 additions and 2 deletions

View File

@ -108,6 +108,14 @@ export function useGoogleMaps() {
clearAllOverlaysForMap(map.value)
}
// 🚀 OPTIMIZACIÓN DE CUOTA: Si el mapa ya existe, no crearlo de nuevo (ahorra cargos de Map Load)
if (map.value && container.contains(map.value.getDiv())) {
console.log('SIBU | Mapa ya inicializado, reutilizando instancia...');
map.value.setCenter(center);
map.value.setZoom(zoom);
return;
}
try {
map.value = new google.maps.Map(container, {
center,

View File

@ -111,8 +111,14 @@ async function animateAndReload() {
showETACard.value = false;
routePhase.value = 'idle';
// Recarga completa del mapa de Google
await initializeMap();
// No es necesario recargar TODO el objeto del mapa, consume cuota innecesariamente.
// Limpiamos y reseteamos el estado visual
if (map.value) {
setCenter(mapStore.center.lat, mapStore.center.lng);
setZoom(mapStore.zoom);
} else {
await initializeMap();
}
setTimeout(() => {
isBannerClosing.value = false;