From 5cb8ab57d67d8f7c72ef6dd98e1f4451dfccb057 Mon Sep 17 00:00:00 2001 From: Alec Georgoff Date: Wed, 6 Aug 2025 11:19:34 -0700 Subject: [PATCH 1/3] Select scooter mode when starting trip from scooter in nearby view --- lib/components/map/default-map.tsx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index e88fa5211..46fe2d18c 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -5,10 +5,11 @@ import { connect } from 'react-redux' import { GeolocateControl, NavigationControl } from 'react-map-gl' import { getCurrentDate } from '@opentripplanner/core-utils/lib/time' import { injectIntl } from 'react-intl' +import { MapLocationActionArg } from '@opentripplanner/types' +import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' import BaseMap from '@opentripplanner/base-map' import generateOTP2TileLayers from '@opentripplanner/otp2-tile-overlay' import React, { Component } from 'react' -import styled from 'styled-components' import { assembleBasePath, @@ -21,7 +22,9 @@ import { ComponentContext } from '../../util/contexts' import { getActiveItinerary, getActiveSearch } from '../../util/state' import { getCurrentPosition } from '../../actions/location' import { MainPanelContent } from '../../actions/ui-constants' +import { onSettingsUpdate } from '../form/util' import { setLocation, setMapPopupLocationAndGeocode } from '../../actions/map' +import { setQueryParam } from '../../actions/form' import { setViewedStop } from '../../actions/ui' import { updateOverlayVisibility } from '../../actions/config' import TransitOperatorIcons from '../util/connected-transit-operator-icons' @@ -278,6 +281,7 @@ class DefaultMap extends Component { carRentalQuery, carRentalStations, config, + currentQuery, getCurrentPosition, intl, itinerary, @@ -285,6 +289,7 @@ class DefaultMap extends Component { nearbyViewActive, pending, setLocation, + setQueryParam, setViewedStop, vehicleRentalQuery, vehicleRentalStations, @@ -319,6 +324,24 @@ class DefaultMap extends Component { const baseLayerUrls = baseLayersWithNames?.map((bl) => bl.url) const baseLayerNames = baseLayersWithNames?.map((bl) => bl.name) + const overlayTypes = overlays + ?.filter((overlay) => overlay?.type === 'otp2')?.[0] + ?.layers?.map((layer) => layer?.type) + const handleSetLocation = (location: MapLocationActionArg) => { + if (overlayTypes && overlayTypes.includes('rentalVehicles')) { + let selectedModeButtons = currentQuery.modeButtons ?? '' + // if selectedModeButtons is undefined, the mode buttons are in their default state, which includes transit + if (selectedModeButtons.length === 0) + selectedModeButtons = 'transit_bike_rent' + else if (!selectedModeButtons.includes('bike_rent')) + selectedModeButtons += '_bike_rent' + console.log('rentalVehicles detected! setting query params') + const evt: QueryParamChangeEvent = { modeButtons: selectedModeButtons } + onSettingsUpdate(setQueryParam)(evt) + } + setLocation(location) + } + const routeBasedTransitVehicleOverlayNameOverride = overlays?.find((o) => o.type === 'vehicles-one-route') || undefined @@ -435,7 +458,7 @@ class DefaultMap extends Component { name: getLayerName(l, config, intl) || l.network || l.type })), vectorTilesEndpoint, - setLocation, + handleSetLocation, setViewedStop, viewedRouteStops, config.companies, @@ -486,6 +509,7 @@ const mapStateToProps = (state) => { bikeRentalStations: state.otp.overlay.bikeRental.stations, carRentalStations: state.otp.overlay.carRental.stations, config: state.otp.config, + currentQuery: state.otp.currentQuery, itinerary: getActiveItinerary(state), mapConfig: state.otp.config.map, nearbyViewActive: @@ -504,6 +528,7 @@ const mapDispatchToProps = { getCurrentPosition, setLocation, setMapPopupLocationAndGeocode, + setQueryParam, setViewedStop, updateOverlayVisibility, vehicleRentalQuery From 85993ff549bb4f699145cd3a999ad5be0f4727f9 Mon Sep 17 00:00:00 2001 From: Alec Georgoff Date: Wed, 6 Aug 2025 11:28:22 -0700 Subject: [PATCH 2/3] Fix missing import --- lib/components/map/default-map.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index 46fe2d18c..52c0c51c8 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -10,6 +10,7 @@ import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' import BaseMap from '@opentripplanner/base-map' import generateOTP2TileLayers from '@opentripplanner/otp2-tile-overlay' import React, { Component } from 'react' +import styled from 'styled-components' import { assembleBasePath, From 29d5d3f0623b07872b3d5cc15b7ca37e876af5e3 Mon Sep 17 00:00:00 2001 From: Alec Georgoff Date: Wed, 6 Aug 2025 11:28:39 -0700 Subject: [PATCH 3/3] Remove console log --- lib/components/map/default-map.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index 52c0c51c8..664019bfc 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -336,7 +336,6 @@ class DefaultMap extends Component { selectedModeButtons = 'transit_bike_rent' else if (!selectedModeButtons.includes('bike_rent')) selectedModeButtons += '_bike_rent' - console.log('rentalVehicles detected! setting query params') const evt: QueryParamChangeEvent = { modeButtons: selectedModeButtons } onSettingsUpdate(setQueryParam)(evt) }