From 5a7c58241ce655f8e97335d1e70c8fae62b4c37b Mon Sep 17 00:00:00 2001 From: itskovacs Date: Wed, 6 Aug 2025 22:36:59 +0200 Subject: [PATCH] :lipstick: Trip itinerary: alternate day colors and connect singleton days --- src/src/app/components/trip/trip.component.ts | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/src/app/components/trip/trip.component.ts b/src/src/app/components/trip/trip.component.ts index 141a569..54572f6 100644 --- a/src/src/app/components/trip/trip.component.ts +++ b/src/src/app/components/trip/trip.component.ts @@ -334,10 +334,7 @@ export class TripComponent implements AfterViewInit { this.totalPrice = this.trip?.days .flatMap((d) => d.items) - .reduce( - (price, item) => price + (item.price ?? item.place?.price ?? 0), - 0, - ) ?? 0; + .reduce((price, item) => price + (item.price ?? 0), 0) ?? 0; } resetPlaceHighlightMarker() { @@ -447,22 +444,33 @@ export class TripComponent implements AfterViewInit { "#e6beff", "#808000", ]; - Object.values(dayGroups).forEach((group, idx) => { - const path = antPath( - group.map((day: any) => [day.lat, day.lng]), - { - delay: 600, - dashArray: [10, 20], - weight: 5, - color: COLORS[idx % 14], - pulseColor: "#FFFFFF", - paused: false, - reverse: false, - hardwareAccelerated: true, - }, - ); + let prevPoint: [number, number] | null = null; + + Object.values(dayGroups).forEach((group, idx) => { + const coords = group.map((day: any) => [day.lat, day.lng]); + const pathOptions = { + delay: 600, + dashArray: [10, 20], + weight: 5, + color: COLORS[idx % COLORS.length], + pulseColor: "#FFFFFF", + paused: false, + reverse: false, + hardwareAccelerated: true, + }; + + if (coords.length >= 2) { + const path = antPath(coords, pathOptions); + layGroup.addLayer(path); + prevPoint = coords[coords.length - 1]; + } else if (coords.length === 1 && prevPoint) { + const path = antPath([prevPoint, coords[0]], pathOptions); + layGroup.addLayer(path); + prevPoint = coords[0]; + } else if (coords.length === 1) { + prevPoint = coords[0]; + } - layGroup.addLayer(path); group.forEach((day: any) => { if (!day.isPlace) layGroup.addLayer(tripDayMarker(day)); });