mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 14:50:00 -07:00
Fix APRS observer location not updating after settings change
Dispatch observer-location-changed event from settings manager and listen for it in APRS mode so manual location saves propagate to the map and distance calculations. Also refresh ObserverLocation in initAprsMap() to catch changes between page load and first map use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1090,6 +1090,14 @@ async function saveObserverLocation() {
|
|||||||
SSTV.loadIssSchedule();
|
SSTV.loadIssSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update APRS user location if function is available
|
||||||
|
if (typeof updateAprsUserLocation === 'function') {
|
||||||
|
updateAprsUserLocation({ latitude: lat, longitude: lon });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify all listeners (any mode can subscribe)
|
||||||
|
window.dispatchEvent(new CustomEvent('observer-location-changed', { detail: { lat, lon } }));
|
||||||
|
|
||||||
if (typeof showNotification === 'function') {
|
if (typeof showNotification === 'function') {
|
||||||
showNotification('Location', notificationMessage);
|
showNotification('Location', notificationMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9875,6 +9875,14 @@
|
|||||||
aprsUserLocation.lon = lon;
|
aprsUserLocation.lon = lon;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Listen for observer location changes from settings or other sources
|
||||||
|
window.addEventListener('observer-location-changed', function(e) {
|
||||||
|
if (e.detail && aprsHasValidCoordinates(e.detail.lat, e.detail.lon)) {
|
||||||
|
updateAprsUserLocation({ latitude: e.detail.lat, longitude: e.detail.lon });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let aprsUserMarker = null;
|
let aprsUserMarker = null;
|
||||||
|
|
||||||
// Calculate distance in miles using Haversine formula
|
// Calculate distance in miles using Haversine formula
|
||||||
@@ -9992,6 +10000,18 @@
|
|||||||
const mapContainer = document.getElementById('aprsMap');
|
const mapContainer = document.getElementById('aprsMap');
|
||||||
if (!mapContainer) return;
|
if (!mapContainer) return;
|
||||||
|
|
||||||
|
// Refresh from ObserverLocation in case it changed since page load
|
||||||
|
if (!aprsHasValidCoordinates(aprsUserLocation.lat, aprsUserLocation.lon) ||
|
||||||
|
(aprsUserLocation.lat === 0 && aprsUserLocation.lon === 0)) {
|
||||||
|
if (typeof ObserverLocation !== 'undefined' && ObserverLocation.getShared) {
|
||||||
|
const shared = ObserverLocation.getShared();
|
||||||
|
if (shared && aprsHasValidCoordinates(shared.lat, shared.lon)) {
|
||||||
|
aprsUserLocation.lat = shared.lat;
|
||||||
|
aprsUserLocation.lon = shared.lon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Use GPS location if available, otherwise default to center of US
|
// Use GPS location if available, otherwise default to center of US
|
||||||
const gpsLat = Number(gpsLastPosition && gpsLastPosition.latitude);
|
const gpsLat = Number(gpsLastPosition && gpsLastPosition.latitude);
|
||||||
const gpsLon = Number(gpsLastPosition && gpsLastPosition.longitude);
|
const gpsLon = Number(gpsLastPosition && gpsLastPosition.longitude);
|
||||||
|
|||||||
Reference in New Issue
Block a user