diff --git a/app/javascript/maps/visits.js b/app/javascript/maps/visits.js index 92438bd7..93ebad3f 100644 --- a/app/javascript/maps/visits.js +++ b/app/javascript/maps/visits.js @@ -192,9 +192,24 @@ export class VisitsManager { this.startPoint = null; this.selectedPoints = []; + // Clear all visit circles immediately + this.visitCircles.clearLayers(); + this.confirmedVisitCircles.clearLayers(); + // If the drawer is open, refresh with time-based visits if (this.drawerOpen) { this.fetchAndDisplayVisits(); + } else { + // If drawer is closed, we should hide all visits + if (this.map.hasLayer(this.visitCircles)) { + this.map.removeLayer(this.visitCircles); + } + } + + // Reset drawer title + const drawerTitle = document.querySelector('#visits-drawer .drawer h2'); + if (drawerTitle) { + drawerTitle.textContent = 'Recent Visits'; } } @@ -376,7 +391,7 @@ export class VisitsManager { const visitsCount = dateGroups[dateStr].count || 0; return ` -