Skip to content
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
2 changes: 2 additions & 0 deletions lib/components/map/default-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import StopsOverlay from './connected-stops-overlay'
import TransitiveOverlay from './connected-transitive-overlay'
import TripViewerOverlay from './connected-trip-viewer-overlay'
import VehicleRentalOverlay from './connected-vehicle-rental-overlay'
import ElevationPointMarker from './elevation-point-marker'
import PointPopup from './point-popup'
import TileOverlay from './tile-overlay'
import ZipcarOverlay from './zipcar-overlay'
Expand Down Expand Up @@ -98,6 +99,7 @@ class DefaultMap extends Component {
<StopViewerOverlay />
<TransitiveOverlay />
<TripViewerOverlay />
<ElevationPointMarker />

{/* The configurable overlays */}
{mapConfig.overlays && mapConfig.overlays.map((overlayConfig, k) => {
Expand Down
53 changes: 53 additions & 0 deletions lib/components/map/elevation-point-marker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { CircleMarker } from 'react-leaflet'

/**
* As the OTP user moves the cursor over the elevation tracking chart
* of a walking or biking leg (to see which point of their itinerary is at which elevation),
* ElevationPointMarker displays and moves a marker on the map to highlight
* the location that corresponds to the cursor position on the elevation chart,
* so the user can see the streets and paths that correspond to a portion of an elevation profile.
*/
class ElevationPointMarker extends Component {
render () {
const { diagramLeg, elevationPoint, showElevationProfile } = this.props

// Compute the elevation point marker, if activeLeg and elevation profile is enabled.
let elevationPointMarker = null
if (showElevationProfile && diagramLeg && elevationPoint) {
const pos = coreUtils.itinerary.legLocationAtDistance(
diagramLeg,
elevationPoint
)
if (pos) {
elevationPointMarker = (
<CircleMarker
center={pos}
fillColor='#084c8d'
weight={6}
color='#555'
opacity={0.4}
radius={5}
fill
fillOpacity={1}
/>
)
}
}
return elevationPointMarker
}
}

const mapStateToProps = (state, ownProps) => {
return {
diagramLeg: state.otp.ui.diagramLeg,
elevationPoint: state.otp.ui.elevationPoint,
showElevationProfile: !!state.otp.config.elevationProfile
}
}

const mapDispatchToProps = {}

export default connect(mapStateToProps, mapDispatchToProps)(ElevationPointMarker)
2 changes: 1 addition & 1 deletion lib/util/itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export function legLocationAtDistance (leg, distance) {

try {
const line = polyline.toGeoJSON(leg.legGeometry.points)
const pt = turfAlong(line, distance, 'meters')
const pt = turfAlong(line, distance, { units: 'meters' })
if (pt && pt.geometry && pt.geometry.coordinates) {
return [
pt.geometry.coordinates[1],
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@
"dependencies": {
"@conveyal/lonlat": "^1.1.0",
"@mapbox/polyline": "^0.2.0",
"@opentripplanner/base-map": "^0.0.19",
"@opentripplanner/core-utils": "^0.0.19",
"@opentripplanner/endpoints-overlay": "^0.0.19",
"@opentripplanner/from-to-location-picker": "^0.0.19",
"@opentripplanner/geocoder": "^0.0.19",
"@opentripplanner/humanize-distance": "^0.0.19",
"@opentripplanner/icons": "^0.0.19",
"@opentripplanner/itinerary-body": "^0.0.19",
"@opentripplanner/location-field": "^0.0.19",
"@opentripplanner/location-icon": "^0.0.19",
"@opentripplanner/park-and-ride-overlay": "^0.0.19",
"@opentripplanner/printable-itinerary": "^0.0.19",
"@opentripplanner/route-viewer-overlay": "^0.0.19",
"@opentripplanner/stop-viewer-overlay": "^0.0.19",
"@opentripplanner/stops-overlay": "^0.0.19",
"@opentripplanner/transitive-overlay": "^0.0.19",
"@opentripplanner/trip-details": "^0.0.19",
"@opentripplanner/trip-form": "^0.0.19",
"@opentripplanner/trip-viewer-overlay": "^0.0.19",
"@opentripplanner/vehicle-rental-overlay": "^0.0.19",
"@opentripplanner/base-map": "^0.0.20",
"@opentripplanner/core-utils": "^0.0.20",
"@opentripplanner/endpoints-overlay": "^0.0.20",
"@opentripplanner/from-to-location-picker": "^0.0.20",
"@opentripplanner/geocoder": "^0.0.20",
"@opentripplanner/humanize-distance": "^0.0.20",
"@opentripplanner/icons": "^0.0.20",
"@opentripplanner/itinerary-body": "^0.0.20",
"@opentripplanner/location-field": "^0.0.20",
"@opentripplanner/location-icon": "^0.0.20",
"@opentripplanner/park-and-ride-overlay": "^0.0.20",
"@opentripplanner/printable-itinerary": "^0.0.20",
"@opentripplanner/route-viewer-overlay": "^0.0.20",
"@opentripplanner/stop-viewer-overlay": "^0.0.20",
"@opentripplanner/stops-overlay": "^0.0.20",
"@opentripplanner/transitive-overlay": "^0.0.20",
"@opentripplanner/trip-details": "^0.0.20",
"@opentripplanner/trip-form": "^0.0.20",
"@opentripplanner/trip-viewer-overlay": "^0.0.20",
"@opentripplanner/vehicle-rental-overlay": "^0.0.20",
"@turf/along": "^6.0.1",
"bootstrap": "^3.3.7",
"clone": "^2.1.0",
Expand Down
Loading