Skip to content

Commit 3cc9f3b

Browse files
authored
feat: 5 Datasets and Polyline highlight on mouseover (#235)
* feat: Five Datasets * Fix: Ensure currentTrips is an array * fix: fix mouse hover on trip polylines
1 parent 90e05a6 commit 3cc9f3b

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

src/App.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ class App extends React.Component {
6666
showLiveJS: getToggleDefault("showLiveJS", false),
6767
showClientServerTimeDeltas: getToggleDefault("showClientServerTimeDeltas", false),
6868
},
69-
uploadedDatasets: [null, null, null],
69+
uploadedDatasets: [null, null, null, null, null],
7070
activeDatasetIndex: null,
7171
activeMenuIndex: null,
72-
selectedRowIndexPerDataset: [-1, -1, -1],
72+
selectedRowIndexPerDataset: [-1, -1, -1, -1, -1],
7373
};
7474
// Realtime updates are too heavy. There must be a better/ react way
7575
this.onSliderChangeDebounced = _.debounce((timeRange) => this.onSliderChange(timeRange), 25);
@@ -446,7 +446,7 @@ class App extends React.Component {
446446

447447
checkUploadedDatasets = async () => {
448448
const newUploadedDatasets = await Promise.all(
449-
[0, 1, 2].map(async (index) => {
449+
[0, 1, 2, 3, 4].map(async (index) => {
450450
const data = await getUploadedData(index);
451451
log(`Dataset ${index}:`, data);
452452
if (data && data.rawLogs && Array.isArray(data.rawLogs) && data.rawLogs.length > 0) {
@@ -921,7 +921,7 @@ class App extends React.Component {
921921
</select>
922922
</div>
923923
</div>
924-
<div className="dataset-controls">{[0, 1, 2].map((index) => this.renderUploadButton(index))}</div>
924+
<div className="dataset-controls">{[0, 1, 2, 3, 4].map((index) => this.renderUploadButton(index))}</div>
925925
<div className="help-text">
926926
<div>All Data remains client side</div>
927927
<div>

src/Map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ function addTripPolys(map) {
6262

6363
_.forEach(trips, (trip) => {
6464
tripObjects.addTripVisuals(trip, minDate, maxDate);
65-
6665
// Update bounds
6766
const tripCoords = trip.getPathCoords(minDate, maxDate);
6867
if (tripCoords.length > 0) {
68+
tripObjects.addTripVisuals(trip, minDate, maxDate);
6969
tripCoords.forEach((coord) => vehicleBounds.extend(coord));
7070
}
7171
});

src/TripLogs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class TripLogs {
451451
return stopsLeft && "Stops Left " + stopsLeft.length;
452452
} else {
453453
const currentTrips = _.get(logEntry, "response.currenttrips");
454-
if (currentTrips) {
454+
if (currentTrips && Array.isArray(currentTrips) && currentTrips.length > 0) {
455455
return currentTrips.join();
456456
}
457457
}

src/TripObjects.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,24 @@ export class TripObjects {
140140
strokeColor: strokeColor,
141141
strokeOpacity: 0.3,
142142
strokeWeight: 6,
143-
clickable: false,
143+
clickable: true,
144+
zIndex: 1,
144145
map: this.map,
145146
});
146147

147-
// Add path events
148148
google.maps.event.addListener(path, "mouseover", () => {
149-
path.setOptions({ strokeOpacity: 1, strokeWeight: 8 });
149+
path.setOptions({ strokeOpacity: 0.7, strokeWeight: 8, zIndex: 100 });
150150
});
151151

152152
google.maps.event.addListener(path, "mouseout", () => {
153-
path.setOptions({ strokeOpacity: 0.5, strokeWeight: 6 });
153+
path.setOptions({ strokeOpacity: 0.3, strokeWeight: 6, zIndex: 1 });
154+
});
155+
156+
// Handle click on polyline but pass the event through to the map
157+
google.maps.event.addListener(path, "click", (event) => {
158+
// Trigger a map click at the same position to maintain selection functionality
159+
google.maps.event.trigger(this.map, "click", event);
160+
return false; // Prevent default action to avoid double handling
154161
});
155162

156163
this.paths.set(tripId, path);

0 commit comments

Comments
 (0)