Skip to content

Commit 363e91b

Browse files
authored
feat: Refine Trip Visualization and Marker Appearance (#257)
* feat: Allow zoom up to 22 * fix: Only use current trip for trip colors for multi trip vehicles * feat: Use trip colors for pickup and drop off * fix: save current parameters to query parameters on fetch * fix: linter
1 parent 0df6729 commit 363e91b

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

src/DatasetLoading.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const CloudLoggingFormComponent = ({ onLogsReceived, onFileUpload }) => {
5353
setLocalError(null);
5454
setFetching(true);
5555
try {
56+
Object.entries(queryParams).forEach(([key, value]) => {
57+
localStorage.setItem(`datasetLoading_${key}`, value);
58+
});
59+
5660
buildQueryFilter(queryParams); // Quick validation
5761
if (isTokenValid()) {
5862
handleCloudLoggingFetch(sessionStorage.getItem("cloudLogging_token"));

src/Map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function MapComponent({
105105
const jsMapView = new window.google.maps.journeySharing.JourneySharingMapView({
106106
element: mapDivRef.current,
107107
locationProviders: [locationProviderRef.current],
108-
mapOptions: { mapId, mapTypeControl: true, streetViewControl: true },
108+
mapOptions: { mapId, mapTypeControl: true, streetViewControl: true, maxZoom: 22 },
109109
});
110110
const map = jsMapView.map;
111111
mapRef.current = map;

src/TripLogs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/TripLogs.js
21
/*
32
* src/TripLogs.js
43
*
@@ -463,7 +462,7 @@ class TripLogs {
463462
} else {
464463
const currentTrips = _.get(logEntry, "response.currenttrips");
465464
if (currentTrips && Array.isArray(currentTrips) && currentTrips.length > 0) {
466-
return currentTrips.join();
465+
return currentTrips[0];
467466
}
468467
}
469468
}

src/TripObjects.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ export class TripObjects {
2121
let points;
2222
if (direction === "up") {
2323
points = [
24-
{ x: 12, y: 20 + shift }, // Top point of chevron
25-
{ x: 8, y: 24 + shift }, // Bottom left
26-
{ x: 16, y: 24 + shift }, // Bottom right
27-
{ x: 12, y: 20 + shift },
24+
{ x: 12, y: 16 + shift }, // Top point of chevron
25+
{ x: 5, y: 24 + shift }, // Bottom left
26+
{ x: 19, y: 24 + shift }, // Bottom right
27+
{ x: 12, y: 16 + shift },
2828
];
2929
} else {
3030
// "down"
3131
points = [
3232
{ x: 12, y: 24 + shift }, // Bottom point of chevron
33-
{ x: 8, y: 20 + shift }, // Top left
34-
{ x: 16, y: 20 + shift }, // Top right
33+
{ x: 5, y: 16 + shift }, // Top left
34+
{ x: 19, y: 16 + shift }, // Top right
3535
{ x: 12, y: 24 + shift },
3636
];
3737
}
3838

39-
return `<path d="M${points[0].x} ${points[0].y}L${points[1].x} ${points[1].y}L${points[2].x} ${points[2].y}L${points[3].x} ${points[3].y}Z" fill="${color}" stroke="${color}" stroke-width="1"/>`;
39+
return `<path d="M${points[0].x} ${points[0].y}L${points[1].x} ${points[1].y}L${points[2].x} ${points[2].y}L${points[3].x} ${points[3].y}Z" fill="${color}" stroke="black" stroke-width="1" stroke-linejoin="round"/>`;
4040
};
4141

4242
const svgBase = `
4343
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
44-
${isActual ? (isPickup ? createChevronPath("up", -4) : createChevronPath("down", -4)) : ""}
44+
${isActual ? (isPickup ? createChevronPath("up", -5) : createChevronPath("down", -5)) : ""}
4545
${isPickup ? createChevronPath("up") : createChevronPath("down")}
4646
</svg>`;
4747

@@ -169,6 +169,7 @@ export class TripObjects {
169169
}
170170

171171
const markers = [];
172+
const tripColor = getColor(trip.tripIdx);
172173

173174
// Get points
174175
const pickupPoint = trip.getPickupPoint();
@@ -177,26 +178,26 @@ export class TripObjects {
177178
const actualDropoffPoint = trip.getActualDropoffPoint();
178179

179180
// Create pickup markers
180-
const pickupMarker = this.createMarkerWithEvents(pickupPoint, "pickup", "#3d633d", actualPickupPoint, tripId);
181+
const pickupMarker = this.createMarkerWithEvents(pickupPoint, "pickup", tripColor, actualPickupPoint, tripId);
181182
if (pickupMarker) markers.push(pickupMarker);
182183

183184
const actualPickupMarker = this.createMarkerWithEvents(
184185
actualPickupPoint,
185186
"actualPickup",
186-
"#3d633d",
187+
tripColor,
187188
pickupPoint,
188189
tripId
189190
);
190191
if (actualPickupMarker) markers.push(actualPickupMarker);
191192

192193
// Create dropoff markers
193-
const dropoffMarker = this.createMarkerWithEvents(dropoffPoint, "dropoff", "#0000FF", actualDropoffPoint, tripId);
194+
const dropoffMarker = this.createMarkerWithEvents(dropoffPoint, "dropoff", tripColor, actualDropoffPoint, tripId);
194195
if (dropoffMarker) markers.push(dropoffMarker);
195196

196197
const actualDropoffMarker = this.createMarkerWithEvents(
197198
actualDropoffPoint,
198199
"actualDropoff",
199-
"#0000FF",
200+
tripColor,
200201
dropoffPoint,
201202
tripId
202203
);

src/localStorage.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("parseJsonContent", () => {
8686
});
8787

8888
it("should throw an error for invalid JSON", () => {
89-
// Temporarily spy on console.error and replace it with a function that does nothing.
89+
// Temporarily spy on console.error and replace it with a function that does nothing.
9090
const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
9191
const invalidJson = "{invalid}";
9292
expect(() => parseJsonContent(invalidJson)).toThrow("Invalid JSON content");

0 commit comments

Comments
 (0)