Add popup persistence and update project docs

- Popups now stay open during live BT tracking updates
- Track open popup device ID and restore after marker refresh
- Update TASKS.md, TODO.md, PROJECT.md, ROADMAP.md
- Mark position smoothing, floor persistence as complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
User
2026-02-01 00:40:57 +01:00
parent dda8455813
commit 5eb5cd2351
5 changed files with 48 additions and 12 deletions

View File

@@ -101,6 +101,7 @@ let map3dDeviceData = {}; // Store device info for popup display
let currentFloor = 'all'; // Will be set to building.currentFloor on init
let map3dInitialized = false;
let map3dLoaded = false;
let openPopupDeviceId = null; // Track which device popup is open
// Initialize on DOM ready
document.addEventListener('DOMContentLoaded', () => {
@@ -1127,6 +1128,14 @@ function update3DMarkers() {
return;
}
// Save currently open popup before removing markers
let savedPopupDeviceId = openPopupDeviceId;
map3dMarkers.forEach(m => {
if (m.getPopup() && m.getPopup().isOpen()) {
savedPopupDeviceId = m._deviceId || savedPopupDeviceId;
}
});
// Remove existing markers
map3dMarkers.forEach(m => m.remove());
map3dMarkers = [];
@@ -1215,6 +1224,9 @@ function update3DMarkers() {
.setLngLat([lon + lonOffset, lat + latOffset])
.setPopup(popup)
.addTo(map3d);
marker._deviceId = wifiDeviceId;
popup.on('open', () => { openPopupDeviceId = wifiDeviceId; });
popup.on('close', () => { if (openPopupDeviceId === wifiDeviceId) openPopupDeviceId = null; });
map3dMarkers.push(marker);
});
@@ -1266,9 +1278,20 @@ function update3DMarkers() {
.setLngLat([lon + lonOffset, lat + latOffset])
.setPopup(popup)
.addTo(map3d);
marker._deviceId = btDeviceId;
popup.on('open', () => { openPopupDeviceId = btDeviceId; });
popup.on('close', () => { if (openPopupDeviceId === btDeviceId) openPopupDeviceId = null; });
map3dMarkers.push(marker);
});
// Reopen saved popup if device still exists
if (savedPopupDeviceId) {
const markerToOpen = map3dMarkers.find(m => m._deviceId === savedPopupDeviceId);
if (markerToOpen && markerToOpen.getPopup()) {
markerToOpen.togglePopup();
}
}
console.log('update3DMarkers:', map3dMarkers.length, 'DOM markers at floor', scannerFloor);
// Update floor device count