Perf/Fix: Resolve Google Maps OverQuotaMapError through marker recycling and instance reuse
This commit is contained in:
@ -108,6 +108,14 @@ export function useGoogleMaps() {
|
|||||||
clearAllOverlaysForMap(map.value)
|
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 {
|
try {
|
||||||
map.value = new google.maps.Map(container, {
|
map.value = new google.maps.Map(container, {
|
||||||
center,
|
center,
|
||||||
|
|||||||
@ -111,8 +111,14 @@ async function animateAndReload() {
|
|||||||
showETACard.value = false;
|
showETACard.value = false;
|
||||||
routePhase.value = 'idle';
|
routePhase.value = 'idle';
|
||||||
|
|
||||||
// Recarga completa del mapa de Google
|
// 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();
|
await initializeMap();
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
isBannerClosing.value = false;
|
isBannerClosing.value = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user