Added Notifications
This commit is contained in:
@@ -455,13 +455,41 @@ export default defineComponent({
|
|||||||
|
|
||||||
const fitBounds = (): void => {
|
const fitBounds = (): void => {
|
||||||
if (!props.flights.length) return
|
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 => {
|
props.flights.forEach(f => {
|
||||||
minLng = Math.min(minLng, f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg)
|
lngs.push(f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg)
|
||||||
maxLng = Math.max(maxLng, f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg)
|
lats.push(f.departure_airport.latitude_deg, f.arrival_airport.latitude_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)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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 })
|
map!.fitBounds([[minLng, minLat], [maxLng, maxLat]], { padding: 60, duration: 0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user