From 3bd2bda84cc8fe26bac2ed8cdc3273de9d147425 Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 19 May 2026 13:02:02 +1000 Subject: [PATCH] Added Notifications --- .../js/Components/FlightsGoneBy/FlightMap.vue | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/resources/js/Components/FlightsGoneBy/FlightMap.vue b/resources/js/Components/FlightsGoneBy/FlightMap.vue index da91656..a478446 100644 --- a/resources/js/Components/FlightsGoneBy/FlightMap.vue +++ b/resources/js/Components/FlightsGoneBy/FlightMap.vue @@ -455,13 +455,41 @@ export default defineComponent({ const fitBounds = (): void => { if (!props.flights.length) return - let minLng = Infinity, maxLng = -Infinity, minLat = Infinity, maxLat = -Infinity + + // Collect all airport coordinates + const lngs: number[] = [] + const lats: number[] = [] props.flights.forEach(f => { - minLng = Math.min(minLng, f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg) - maxLng = Math.max(maxLng, f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg) - minLat = Math.min(minLat, f.departure_airport.latitude_deg, f.arrival_airport.latitude_deg) - maxLat = Math.max(maxLat, f.departure_airport.latitude_deg, f.arrival_airport.latitude_deg) + lngs.push(f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg) + lats.push(f.departure_airport.latitude_deg, f.arrival_airport.latitude_deg) }) + + const minLat = Math.min(...lats) + const maxLat = Math.max(...lats) + + // Check if wrapping across the dateline gives a tighter span + const minLngNormal = Math.min(...lngs) + const maxLngNormal = Math.max(...lngs) + const spanNormal = maxLngNormal - minLngNormal + + // Shift negative longitudes into the 0–360 range and recompute span + const lngs360 = lngs.map(lng => lng < 0 ? lng + 360 : lng) + const minLng360 = Math.min(...lngs360) + const maxLng360 = Math.max(...lngs360) + const span360 = maxLng360 - minLng360 + + let minLng: number + let maxLng: number + + if (span360 < spanNormal) { + // Dateline-crossing view is tighter — use the shifted coords + minLng = minLng360 > 180 ? minLng360 - 360 : minLng360 + maxLng = maxLng360 > 180 ? maxLng360 - 360 : maxLng360 + } else { + minLng = minLngNormal + maxLng = maxLngNormal + } + map!.fitBounds([[minLng, minLat], [maxLng, maxLat]], { padding: 60, duration: 0 }) }