Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transit vehicle overlay show longname #708

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/transit-vehicle-overlay/src/VehicleTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ const Title = styled.span`
export default function VehicleTooltip({
vehicle
}: VehicleComponentProps): JSX.Element {
const { routeShortName, routeType, seconds } = vehicle;
const { routeShortName, routeLongName, routeType, seconds } = vehicle;

let name: JSX.Element = <>{routeShortName}</>;
const routeName = routeShortName || routeLongName;

let name: JSX.Element = <>{routeName}</>;
// This condition avoids processing long route names such as "Portland Streetcar".
if (routeShortName?.length <= 5) {
if (routeName?.length <= 5) {
// This produces text such as "MAX Green", "BUS 157",
// or "Line A" if no routeType is provided.
name = (
Expand All @@ -29,7 +31,7 @@ export default function VehicleTooltip({
description="Formats a route title"
id="otpUi.TransitVehicleOverlay.routeTitle"
values={{
name: routeShortName,
name: routeName,
type: routeType || (
<FormattedMessage
defaultMessage={
Expand Down
4 changes: 3 additions & 1 deletion packages/transit-vehicle-overlay/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const TransitVehicleOverlay = ({
popupProps={{ offset: [-iconPixels / 2 - iconPadding, 0] }}
position={[vehicle.lat, vehicle.lon]}
tooltipContents={
vehicle.routeShortName && <TooltipSlot vehicle={vehicle} />
(vehicle.routeShortName || vehicle.routeLongName) && (
<TooltipSlot vehicle={vehicle} />
)
}
>
<StyledContainer vehicle={vehicle}>
Expand Down
Loading