diff --git a/templates/adsb_dashboard.html b/templates/adsb_dashboard.html index f220e11..9b7f954 100644 --- a/templates/adsb_dashboard.html +++ b/templates/adsb_dashboard.html @@ -621,10 +621,14 @@ Show Range Rings - -
51.5074, -0.1278
@@ -929,13 +933,41 @@ rangeRingsLayer.addTo(radarMap); } - // Get user geolocation + // Update observer location from input fields + function updateObserverLoc() { + const latInput = document.getElementById('obsLat'); + const lonInput = document.getElementById('obsLon'); + + if (latInput && lonInput) { + const lat = parseFloat(latInput.value); + const lon = parseFloat(lonInput.value); + + if (!isNaN(lat) && !isNaN(lon) && lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180) { + observerLocation.lat = lat; + observerLocation.lon = lon; + + if (radarMap) { + radarMap.setView([observerLocation.lat, observerLocation.lon], 8); + } + + drawRangeRings(); + } + } + } + + // Get user geolocation (only works on HTTPS or localhost) function getGeolocation() { if (!navigator.geolocation) { alert('Geolocation not supported'); return; } + // Check if we're on a secure context + if (!window.isSecureContext) { + alert('GPS location requires HTTPS. Please enter your coordinates manually in the lat/lon fields above.'); + return; + } + const btn = document.getElementById('geolocateBtn'); if (btn) btn.textContent = '📍 Locating...'; @@ -944,19 +976,22 @@ observerLocation.lat = position.coords.latitude; observerLocation.lon = position.coords.longitude; - const locEl = document.getElementById('observerLoc'); - if (locEl) locEl.textContent = `${observerLocation.lat.toFixed(4)}, ${observerLocation.lon.toFixed(4)}`; + // Update input fields + const latInput = document.getElementById('obsLat'); + const lonInput = document.getElementById('obsLon'); + if (latInput) latInput.value = observerLocation.lat.toFixed(4); + if (lonInput) lonInput.value = observerLocation.lon.toFixed(4); if (radarMap) { radarMap.setView([observerLocation.lat, observerLocation.lon], 8); } drawRangeRings(); - if (btn) btn.textContent = '📍 My Location'; + if (btn) btn.textContent = '📍 Use GPS'; }, (error) => { - alert('Location error: ' + error.message); - if (btn) btn.textContent = '📍 My Location'; + alert('Unable to get location. Please enter coordinates manually.\n\nError: ' + error.message); + if (btn) btn.textContent = '📍 Use GPS'; }, { enableHighAccuracy: true, timeout: 10000 } ); diff --git a/templates/index.html b/templates/index.html index a789779..82ca6c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3207,11 +3207,15 @@ Show Range Rings
- -
- 51.5074, -0.1278 +
+ +
+ + +
+
@@ -8257,13 +8261,44 @@ rangeRingsLayer.addTo(aircraftMap); } - // Get user's geolocation + // Update observer location from input fields + function updateObserverLocation() { + const latInput = document.getElementById('adsbObsLat'); + const lonInput = document.getElementById('adsbObsLon'); + + if (latInput && lonInput) { + const lat = parseFloat(latInput.value); + const lon = parseFloat(lonInput.value); + + if (!isNaN(lat) && !isNaN(lon) && lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180) { + observerLocation.lat = lat; + observerLocation.lon = lon; + + // Center map on location + if (aircraftMap) { + aircraftMap.setView([observerLocation.lat, observerLocation.lon], 8); + aircraftMap._userInteracted = true; + } + + // Redraw range rings + drawRangeRings(); + } + } + } + + // Get user's geolocation (only works on HTTPS or localhost) function getAdsbGeolocation() { if (!navigator.geolocation) { alert('Geolocation is not supported by your browser'); return; } + // Check if we're on a secure context + if (!window.isSecureContext) { + alert('GPS location requires HTTPS. Please enter your coordinates manually in the lat/lon fields above.'); + return; + } + const btn = document.getElementById('adsbGeolocateBtn'); if (btn) btn.textContent = '📍 Locating...'; @@ -8272,27 +8307,27 @@ observerLocation.lat = position.coords.latitude; observerLocation.lon = position.coords.longitude; - // Update display - const locDisplay = document.getElementById('adsbObserverLoc'); - if (locDisplay) { - locDisplay.textContent = `${observerLocation.lat.toFixed(4)}, ${observerLocation.lon.toFixed(4)}`; - } + // Update input fields + const latInput = document.getElementById('adsbObsLat'); + const lonInput = document.getElementById('adsbObsLon'); + if (latInput) latInput.value = observerLocation.lat.toFixed(4); + if (lonInput) lonInput.value = observerLocation.lon.toFixed(4); // Center map on location if (aircraftMap) { aircraftMap.setView([observerLocation.lat, observerLocation.lon], 8); - aircraftMap._userInteracted = true; // Prevent auto-fit + aircraftMap._userInteracted = true; } // Redraw range rings drawRangeRings(); - if (btn) btn.textContent = '📍 My Location'; + if (btn) btn.textContent = '📍 Use GPS Location'; showInfo(`Location set: ${observerLocation.lat.toFixed(4)}, ${observerLocation.lon.toFixed(4)}`); }, (error) => { - if (btn) btn.textContent = '📍 My Location'; - alert('Unable to get your location: ' + error.message); + if (btn) btn.textContent = '📍 Use GPS Location'; + alert('Unable to get location. Please enter coordinates manually.\n\nError: ' + error.message); }, { enableHighAccuracy: true, timeout: 10000 } );