mirror of
https://github.com/smittix/intercept.git
synced 2026-06-29 21:52:08 -07:00
Retry ADS-B map bootstrap safely
This commit is contained in:
@@ -441,6 +441,7 @@
|
|||||||
let mapCrosshairRequestId = 0;
|
let mapCrosshairRequestId = 0;
|
||||||
let detectedDevicesPromise = null;
|
let detectedDevicesPromise = null;
|
||||||
let deviceDetectionRetryTimer = null;
|
let deviceDetectionRetryTimer = null;
|
||||||
|
let mapBootstrapRetryTimer = null;
|
||||||
let clockInterval = null;
|
let clockInterval = null;
|
||||||
let cleanupInterval = null;
|
let cleanupInterval = null;
|
||||||
let delayedGpsInitTimer = null;
|
let delayedGpsInitTimer = null;
|
||||||
@@ -1735,6 +1736,7 @@ ACARS: ${r.statistics.acarsMessages} messages`;
|
|||||||
if (delayedDriverCheckTimer) { clearTimeout(delayedDriverCheckTimer); delayedDriverCheckTimer = null; }
|
if (delayedDriverCheckTimer) { clearTimeout(delayedDriverCheckTimer); delayedDriverCheckTimer = null; }
|
||||||
if (delayedAircraftDbTimer) { clearTimeout(delayedAircraftDbTimer); delayedAircraftDbTimer = null; }
|
if (delayedAircraftDbTimer) { clearTimeout(delayedAircraftDbTimer); delayedAircraftDbTimer = null; }
|
||||||
if (deviceDetectionRetryTimer) { clearTimeout(deviceDetectionRetryTimer); deviceDetectionRetryTimer = null; }
|
if (deviceDetectionRetryTimer) { clearTimeout(deviceDetectionRetryTimer); deviceDetectionRetryTimer = null; }
|
||||||
|
if (mapBootstrapRetryTimer) { clearTimeout(mapBootstrapRetryTimer); mapBootstrapRetryTimer = null; }
|
||||||
});
|
});
|
||||||
|
|
||||||
function ensureAdsbMapBootstrapped() {
|
function ensureAdsbMapBootstrapped() {
|
||||||
@@ -2294,12 +2296,45 @@ sudo make install</code>
|
|||||||
const container = document.getElementById('radarMap');
|
const container = document.getElementById('radarMap');
|
||||||
if (!container || container._leaflet_id) return;
|
if (!container || container._leaflet_id) return;
|
||||||
|
|
||||||
radarMap = L.map('radarMap', {
|
if (typeof L === 'undefined' || typeof L.map !== 'function') {
|
||||||
center: [observerLocation.lat, observerLocation.lon],
|
if (!mapBootstrapRetryTimer) {
|
||||||
zoom: 7,
|
mapBootstrapRetryTimer = setTimeout(() => {
|
||||||
minZoom: 3,
|
mapBootstrapRetryTimer = null;
|
||||||
maxZoom: 15
|
ensureAdsbMapBootstrapped();
|
||||||
});
|
}, 300);
|
||||||
|
}
|
||||||
|
console.warn('ADS-B: Leaflet not ready yet, retrying map bootstrap');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedLocation = (window.ObserverLocation && typeof ObserverLocation.normalize === 'function')
|
||||||
|
? ObserverLocation.normalize(observerLocation?.lat, observerLocation?.lon)
|
||||||
|
: null;
|
||||||
|
const defaultLocation = {
|
||||||
|
lat: Number(window.INTERCEPT_DEFAULT_LAT ?? 51.5074),
|
||||||
|
lon: Number(window.INTERCEPT_DEFAULT_LON ?? -0.1278)
|
||||||
|
};
|
||||||
|
const initialLocation = normalizedLocation || defaultLocation;
|
||||||
|
|
||||||
|
observerLocation = initialLocation;
|
||||||
|
|
||||||
|
try {
|
||||||
|
radarMap = L.map('radarMap', {
|
||||||
|
center: [initialLocation.lat, initialLocation.lon],
|
||||||
|
zoom: 7,
|
||||||
|
minZoom: 3,
|
||||||
|
maxZoom: 15
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('ADS-B: L.map() failed:', e);
|
||||||
|
if (!mapBootstrapRetryTimer) {
|
||||||
|
mapBootstrapRetryTimer = setTimeout(() => {
|
||||||
|
mapBootstrapRetryTimer = null;
|
||||||
|
ensureAdsbMapBootstrapped();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Use settings manager for tile layer (allows runtime changes)
|
// Use settings manager for tile layer (allows runtime changes)
|
||||||
window.radarMap = radarMap;
|
window.radarMap = radarMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user