-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment with showing all vehicles at once
- Loading branch information
1 parent
8c85cb8
commit d6b44bb
Showing
8 changed files
with
118 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
lib/components/map/connected-full-transit-vehicle-overlay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { connect } from 'react-redux' | ||
Check failure on line 1 in lib/components/map/connected-full-transit-vehicle-overlay.tsx GitHub Actions / test-build-release
Check failure on line 1 in lib/components/map/connected-full-transit-vehicle-overlay.tsx GitHub Actions / test-build-release
Check failure on line 1 in lib/components/map/connected-full-transit-vehicle-overlay.tsx GitHub Actions / test-build-release
|
||
import { injectIntl } from 'react-intl' | ||
import React from 'react' | ||
import TransitVehicleOverlay, { | ||
Circle, | ||
DefaultIconContainer, | ||
RotatingCircle, | ||
RouteNumberIcon, | ||
withRouteColorBackground | ||
} from '@opentripplanner/transit-vehicle-overlay' | ||
|
||
import { DEFAULT_ROUTE_COLOR } from '../util/colors' | ||
|
||
import { VehicleTooltip } from './connected-transit-vehicle-overlay' | ||
|
||
const IconContainer = withRouteColorBackground(Circle) | ||
// connect to the redux store | ||
const mapStateToProps = (state: Record<string, any>) => { | ||
const { viewedRoute } = state.otp.ui | ||
// TODO: clever behavior for when route viewer is active | ||
|
||
const vehicles = state.otp.transitIndex?.allVehicles | ||
// TODO: CLEAN THIS UP | ||
?.filter( | ||
(obj, index) => | ||
state.otp.transitIndex?.allVehicles.findIndex( | ||
(item) => item.vehicleId === obj.vehicleId | ||
) === index | ||
) | ||
.map((v) => { | ||
const { route } = v?.trip | ||
v.routeType = route?.mode | ||
v.routeColor = | ||
route.color && !route.color.includes('#') | ||
? '#' + route.color | ||
: route?.color || DEFAULT_ROUTE_COLOR | ||
// Try to populate this attribute, which is required for the vehicle popup to appear. | ||
v.routeShortName = route?.shortName | ||
v.routeLongName = v.routeLongName || route?.longName | ||
v.textColor = route?.textColor | ||
return v | ||
}) | ||
|
||
// TODO: something funky is happening with the mode icon. Ferries are buses! | ||
return { | ||
IconContainer, | ||
TooltipSlot: injectIntl(VehicleTooltip), | ||
VehicleIcon: RouteNumberIcon, | ||
vehicles | ||
} | ||
} | ||
|
||
// @ts-expect-error state.js being typescripted will fix this error | ||
export default injectIntl(connect(mapStateToProps)(TransitVehicleOverlay)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters