Refaktoring a pridani letiste mezipristani do mapy

This commit is contained in:
Michal Kváček
2023-10-07 22:11:56 +02:00
parent 901c652641
commit e76d34fab4
+8 -35
View File
@@ -14,43 +14,16 @@ const props = defineProps({
const mapPhotos = computed(() => flight.value.photos.filter(photo => photo.gpsLatitude && photo.gpsLongitude));
const poisWithGPS = computed(() => {
return flight.value.track.filter(poi => poi.pointOfInterest?.gpsLatitude && poi.pointOfInterest?.gpsLongitude)
});
const pointsOfInterests = computed(() => {
const path = [];
if (flight.value.takeoffAirport.gpsLatitude && flight.value.takeoffAirport.gpsLongitude) {
path.push({
label: flight.value.takeoffAirport.name,
position:
{
lat: flight.value.takeoffAirport.gpsLatitude,
lng: flight.value.takeoffAirport.gpsLongitude
}
});
}
for (const poi of poisWithGPS.value) {
path.push({
label: poi.pointOfInterest.name,
position: {lat: poi.pointOfInterest.gpsLatitude, lng: poi.pointOfInterest.gpsLongitude}
});
}
if (flight.value.landingAirport.gpsLatitude && flight.value.landingAirport.gpsLongitude) {
path.push({
label: flight.value.landingAirport.name,
position: {
lat: flight.value.landingAirport.gpsLatitude,
lng: flight.value.landingAirport.gpsLongitude
}
});
}
return path;
return flight.value.track.filter(poi => {
const item = poi.pointOfInterest || poi.airport;
return item.gpsLatitude && item.gpsLongitude;
}).map(poi => poi.pointOfInterest || poi.airport)
});
const mapMarkers = [flight.value.takeoffAirport].concat(poisWithGPS.value).concat([flight.value.landingAirport]);
const pointsOfInterests = computed(() => mapMarkers.map(
marker => ({label: marker.name, position: {lat: marker.gpsLatitude, lng: marker.gpsLongitude}})
));
const gpxTrack = flight.value.gpxTrack;