Skip to content

Commit

Permalink
Merge pull request #1270 from opentripplanner/show-stops-in-route-viewer
Browse files Browse the repository at this point in the history
set `viewedRouteStops` when route viewer is active
  • Loading branch information
miles-grant-ibigroup authored Sep 25, 2024
2 parents 9a56086 + b944509 commit 818ac7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions lib/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ class DefaultMap extends Component {
setLocation,
setViewedStop,
vehicleRentalQuery,
vehicleRentalStations
vehicleRentalStations,
viewedRouteStops
} = this.props
const { getCustomMapOverlays, getTransitiveRouteLabel, ModeIcon } =
this.context
Expand Down Expand Up @@ -405,7 +406,7 @@ class DefaultMap extends Component {
vectorTilesEndpoint,
setLocation,
setViewedStop,
null,
viewedRouteStops,
config.companies
)
default:
Expand All @@ -428,6 +429,26 @@ class DefaultMap extends Component {

const mapStateToProps = (state) => {
const activeSearch = getActiveSearch(state)
const viewedRoute = state.otp?.ui?.viewedRoute?.routeId
const nearbyViewerActive =
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW

const viewedRoutePatterns = Object.entries(
state.otp?.transitIndex?.routes?.[viewedRoute]?.patterns || {}
)
const viewedRouteStops =
viewedRoute && !nearbyViewerActive
? // Ensure we don't have duplicates
Array.from(
new Set(
// Generate a list of every stop id the pattern stops at
viewedRoutePatterns.reduce((acc, cur) => {
// Convert pattern object to list of the pattern's stops
return [...cur?.[1]?.stops.map((s) => s.id), ...acc]
}, [])
)
)
: null

return {
bikeRentalStations: state.otp.overlay.bikeRental.stations,
Expand All @@ -439,7 +460,8 @@ const mapStateToProps = (state) => {
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW,
pending: activeSearch ? Boolean(activeSearch.pending) : false,
query: state.otp.currentQuery,
vehicleRentalStations: state.otp.overlay.vehicleRental.stations
vehicleRentalStations: state.otp.overlay.vehicleRental.stations,
viewedRouteStops
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/components/map/point-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function MapPopup({
// Override inline style supplied by react-map-gl to accommodate long "plan a trip" translations.
style={{ maxWidth: '260px', width: '260px' }}
>
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="stop-popup">
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="point-popup">
<PopupTitleWrapper>
<PopupTitle>
{typeof popupName === 'string' && popupName.split(',').length > 3
Expand Down

0 comments on commit 818ac7d

Please sign in to comment.