Skip to content

Commit

Permalink
feat: add map. autoFlyOnTripFormUpdate config key
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed May 29, 2024
1 parent bf505a4 commit caece52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ persistence:
map:
initLat: 45.52
initLon: -122.682
# autoFlyOnTripFormUpdate: false
baseLayers:
- name: Streets
# These tiles are free to use, but not in production
Expand Down
24 changes: 14 additions & 10 deletions lib/components/app/responsive-webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ResponsiveWebapp extends Component {
componentDidUpdate(prevProps) {
const {
activeSearchId,
autoFly,
currentPosition,
formChanged,
intl,
Expand Down Expand Up @@ -99,15 +100,17 @@ class ResponsiveWebapp extends Component {
setLocationToCurrent({ locationType: 'from' }, intl)
setMapCenter(map, pt)
}
} else if (query.from && query.to && mainPanelContent === null) {
map?.fitBounds([query.from, query.to], {
duration: 600,
padding: getFitBoundsPadding(map, 0.2)
})
} else if (query.from && !query.to) {
setMapCenter(map, query.from)
} else if (query.to && !query.from) {
setMapCenter(map, query.to)
} else if (mainPanelContent === null && autoFly !== false) {
if (query.from && query.to) {
map?.fitBounds([query.from, query.to], {
duration: 600,
padding: getFitBoundsPadding(map, 0.2)
})
} else if (query.from && !query.to) {
setMapCenter(map, query.from)
} else if (query.to && !query.from) {
setMapCenter(map, query.to)
}
}

// If the path changes (e.g., via a back button press) check whether the
Expand Down Expand Up @@ -417,9 +420,10 @@ class RouterWrapperWithAuth0 extends Component {
}

const mapStateToWrapperProps = (state) => {
const { homeTimezone, persistence, reactRouter } = state.otp.config
const { homeTimezone, map, persistence, reactRouter } = state.otp.config
return {
auth0Config: getAuth0Config(persistence),
autoFly: map.autoFlyOnTripFormUpdate,
defaultLocale: getDefaultLocale(state.otp.config, state.user.loggedInUser),
homeTimezone,
locale: state.otp.ui.locale,
Expand Down
1 change: 1 addition & 0 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export type SupportedOverlays =
| MapTileLayerConfig

export interface MapConfig {
autoFlyOnTripFormUpdate?: boolean
baseLayers?: BaseLayerConfig[]
initLat?: number
initLon?: number
Expand Down

0 comments on commit caece52

Please sign in to comment.