@@ -27,6 +27,7 @@ let locationProvider;
2727let tripLogs ;
2828let taskLogs ;
2929let setFeaturedObject ;
30+ let focusSelectedRow ;
3031let setTimeRange ;
3132
3233const render = ( status ) => {
@@ -54,6 +55,8 @@ function addTripPolys(map) {
5455 if ( closestEvent ) {
5556 log ( "Found closest event:" , closestEvent . timestamp ) ;
5657 setFeaturedObject ( closestEvent ) ;
58+
59+ setTimeout ( ( ) => focusSelectedRow ( ) , 0 ) ;
5760 }
5861 } ) ;
5962
@@ -133,11 +136,6 @@ function MyMapComponent(props) {
133136 map . setHeading ( parseInt ( urlHeading ) ) ;
134137 }
135138 map . setOptions ( { maxZoom : 100 } ) ;
136- map . addListener ( "zoom_changed" , ( ) => {
137- setQueryStringValue ( "zoom" , map . getZoom ( ) ) ;
138- setIsFollowingVehicle ( false ) ; // zoom disables following
139- log ( "Follow mode disabled due to zoom change" ) ;
140- } ) ;
141139
142140 map . addListener ( "heading_changed" , ( ) => {
143141 setQueryStringValue ( "heading" , map . getHeading ( ) ) ;
@@ -318,7 +316,35 @@ function MyMapComponent(props) {
318316 // Update the polylines state to remove all route segments
319317 setPolylines ( polylines . filter ( ( p ) => ! p . isRouteSegment ) ) ;
320318
321- // Get the current route segment from the selected row
319+ const eventType = props . selectedRow [ "@type" ] ;
320+ const isTripEvent = [ "getTrip" , "updateTrip" , "createTrip" ] . includes ( eventType ) ;
321+
322+ if ( isTripEvent ) {
323+ // Create a thin red polyline with arrows for trip events
324+ const routeSegment = _ . get ( props . selectedRow , "response.currentroutesegment" ) ;
325+ if ( routeSegment ) {
326+ try {
327+ const decodedPoints = decode ( routeSegment ) ;
328+ if ( decodedPoints && decodedPoints . length > 0 ) {
329+ const validWaypoints = decodedPoints . map ( ( point ) => ( {
330+ lat : point . latDegrees ( ) ,
331+ lng : point . lngDegrees ( ) ,
332+ } ) ) ;
333+
334+ const trafficPolyline = new TrafficPolyline ( {
335+ path : validWaypoints ,
336+ zIndex : 3 ,
337+ isTripEvent : true ,
338+ map : map ,
339+ } ) ;
340+ setPolylines ( ( prev ) => [ ...prev , ...trafficPolyline . polylines ] ) ;
341+ }
342+ } catch ( error ) {
343+ console . error ( "Error processing trip event polyline:" , error ) ;
344+ }
345+ }
346+ }
347+
322348 const routeSegment =
323349 _ . get ( props . selectedRow , "request.vehicle.currentroutesegment" ) ||
324350 _ . get ( props . selectedRow , "lastlocation.currentroutesegment" ) ;
@@ -337,23 +363,19 @@ function MyMapComponent(props) {
337363 _ . get ( props . selectedRow , "request.vehicle.currentroutesegmenttraffic.trafficrendering" ) ||
338364 _ . get ( props . selectedRow , "lastlocation.currentroutesegmenttraffic.trafficrendering" ) ;
339365
340- const rawLocation = _ . get ( props . selectedRow . lastlocation , "rawlocation " ) ;
366+ const location = _ . get ( props . selectedRow . lastlocation , "location " ) ;
341367
342368 const trafficPolyline = new TrafficPolyline ( {
343369 path : validWaypoints ,
344370 zIndex : 2 ,
345371 trafficRendering : structuredClone ( trafficRendering ) ,
346- currentLatLng : rawLocation ,
372+ currentLatLng : location ,
347373 map : map ,
348374 } ) ;
349375 setPolylines ( ( prev ) => [ ...prev , ...trafficPolyline . polylines ] ) ;
350376 }
351377 } catch ( error ) {
352- console . error ( "Error processing route segment polyline:" , {
353- error,
354- routeSegment,
355- rowData : props . selectedRow ,
356- } ) ;
378+ console . error ( "Error processing route segment polyline:" , error ) ;
357379 }
358380 }
359381 } , [ props . selectedRow ] ) ;
@@ -384,34 +406,55 @@ function MyMapComponent(props) {
384406 strokeWeight : 1 ,
385407 rotation : 0 ,
386408 } ,
409+ rawLocation : {
410+ path : google . maps . SymbolPath . CIRCLE ,
411+ fillColor : "#FF0000" ,
412+ fillOpacity : 1 ,
413+ scale : 2 ,
414+ strokeColor : "#FF0000" ,
415+ strokeWeight : 1 ,
416+ } ,
387417 } ;
388418
389- const rawLocation = _ . get ( data . lastlocation , "rawlocation " ) ;
390- if ( rawLocation ) {
391- lastValidPositionRef . current = { lat : rawLocation . latitude , lng : rawLocation . longitude } ;
419+ const location = _ . get ( data . lastlocation , "location" ) || _ . get ( data . lastlocationResponse , "location ") ;
420+ if ( location ) {
421+ lastValidPositionRef . current = { lat : location . latitude , lng : location . longitude } ;
392422
393- const heading = _ . get ( data . lastlocation , "heading" ) || 0 ;
423+ const heading = _ . get ( data . lastlocation , "heading" ) || _ . get ( data . lastlocationResponse , "heading" ) || 0 ;
394424 markerSymbols . chevron . rotation = heading ;
395425
396426 const backgroundMarker = new window . google . maps . Marker ( {
397- position : { lat : rawLocation . latitude , lng : rawLocation . longitude } ,
427+ position : { lat : location . latitude , lng : location . longitude } ,
398428 map : map ,
399429 icon : markerSymbols . background ,
400430 clickable : false ,
401431 zIndex : 9 ,
402432 } ) ;
403433
404434 const chevronMarker = new window . google . maps . Marker ( {
405- position : { lat : rawLocation . latitude , lng : rawLocation . longitude } ,
435+ position : { lat : location . latitude , lng : location . longitude } ,
406436 map : map ,
407437 icon : markerSymbols . chevron ,
408438 zIndex : 10 ,
409439 } ) ;
410440
411441 dataMakers . push ( backgroundMarker , chevronMarker ) ;
412442
443+ const rawLocation = _ . get ( data . lastlocation , "rawlocation" ) ;
444+ if ( rawLocation ) {
445+ const rawLocationMarker = new window . google . maps . Marker ( {
446+ position : { lat : rawLocation . latitude , lng : rawLocation . longitude } ,
447+ map : map ,
448+ icon : markerSymbols . rawLocation ,
449+ zIndex : 8 ,
450+ clickable : false ,
451+ } ) ;
452+
453+ dataMakers . push ( rawLocationMarker ) ;
454+ }
455+
413456 if ( isFollowingVehicle ) {
414- map . setCenter ( { lat : rawLocation . latitude , lng : rawLocation . longitude } ) ;
457+ map . setCenter ( { lat : location . latitude , lng : location . longitude } ) ;
415458 }
416459 }
417460 } , [ props . selectedRow , isFollowingVehicle ] ) ;
@@ -449,6 +492,7 @@ function Map(props) {
449492 jwt = props . logData . jwt ;
450493 projectId = props . logData . projectId ;
451494 setFeaturedObject = props . setFeaturedObject ;
495+ focusSelectedRow = props . focusSelectedRow ;
452496 setTimeRange = props . setTimeRange ;
453497
454498 function centerOnLocation ( lat , lng ) {
0 commit comments