diff --git a/index.html b/index.html index fb356a9..80d9543 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - IndyConnect + Conveyal Analysis diff --git a/src/actions/browsochrones.js b/src/actions/browsochrones.js index 8d75c3c..235c7cf 100644 --- a/src/actions/browsochrones.js +++ b/src/actions/browsochrones.js @@ -17,7 +17,8 @@ import { setEnd, setEndLabel, setStart, - setStartLabel + setStartLabel, + updateMap } from '../actions' import type {Store} from '../types' @@ -42,8 +43,14 @@ export default function initialize ({ ), geocodeQs({geocoder, qs}).then(([start, end]) => { const actions = [] - if (start) actions.push(setStart(start)) + if (start) { + actions.push(setStart(start)) + actions.push( + updateMap({centerCoordinates: lonlat.toLeaflet(start.latlng)}) + ) + } if (end) actions.push(setEnd(end)) + if (qs.zoom) actions.push(updateMap({zoom: parseInt(qs.zoom, 10)})) actions.push( fetchGrids(browsochrones) .then(grids => diff --git a/src/components/application.js b/src/components/application.js index 0b9de8d..1c42139 100644 --- a/src/components/application.js +++ b/src/components/application.js @@ -114,13 +114,7 @@ export default class Application extends Component { return markers } - _setStart = ({ - label, - latlng - }: { - label?: string, - latlng: Coordinate - }) => { + _setStart = ({label, latlng}: {label?: string, latlng: Coordinate}) => { const {browsochrones, map, mapMarkers, timeCutoff, updateStart} = this.props const endLatlng = mapMarkers.end && mapMarkers.end.latlng ? mapMarkers.end.latlng @@ -153,13 +147,7 @@ export default class Application extends Component { } } - _setEnd = ({ - label, - latlng - }: { - label?: string, - latlng: Coordinate - }) => { + _setEnd = ({label, latlng}: {label?: string, latlng: Coordinate}) => { const {browsochrones, map, mapMarkers, updateEnd} = this.props updateEnd({ browsochronesInstances: browsochrones.instances, @@ -221,10 +209,10 @@ export default class Application extends Component {
{ actionLog && actionLog.length > 0 &&
-
{messages.Log.Title}
+
+ {messages.Log.Title} +
}
diff --git a/src/components/form.js b/src/components/form.js index 523b616..58b0e81 100644 --- a/src/components/form.js +++ b/src/components/form.js @@ -50,7 +50,9 @@ export default ({ start }: Props) => (
-
{messages.Geocoding.StartTitle}
+
+ {messages.Geocoding.StartTitle} +
{start &&
-
{messages.Geocoding.EndTitle}
+
+ {messages.Geocoding.EndTitle} +
( {formatDate(props.createdAt, FORMAT)} - {props.text} + + {props.text} +
) diff --git a/src/components/map.js b/src/components/map.js index 60a87e7..139bf86 100644 --- a/src/components/map.js +++ b/src/components/map.js @@ -11,6 +11,7 @@ import { } from 'react-leaflet' import Icon from './icon' +import {setKeyTo} from '../utils/hash' import leafletIcon from '../utils/leaflet-icons' import messages from '../utils/messages' import TransitiveLayer from './transitive-map-layer' @@ -33,10 +34,10 @@ const endIcon = leafletIcon({ }) type Props = { + active: number, centerCoordinates: Coordinate, clearStartAndEnd(): void, - geojson: Feature[], - geojsonColor: string, + isochrones: any[], markers: any[], pointsOfInterest: PointsOfInterest, setEnd(any): void, @@ -107,11 +108,15 @@ export default class Map extends PureComponent { }) } + _setZoom = (e: MapEvent) => { + setKeyTo('zoom', e.target._zoom) + } + render (): React$Element { const { + active, centerCoordinates, - geojson, - geojsonColor, + isochrones, markers, pointsOfInterest, transitive, @@ -129,11 +134,15 @@ export default class Map extends PureComponent { tileLayerProps.zoomOffset = -1 } + const baseIsochrone = isochrones[0] + const comparisonIsochrone = active !== 0 ? isochrones[active] : null + return ( { onDragEnd={m.onDragEnd} position={m.position} > - {m.label && {m.label}} + {m.label && + + + {m.label} + + } ))} - {geojson.map(g => { - return ( - - ) - })} + {baseIsochrone && + } + + {comparisonIsochrone && + } {transitive && } @@ -184,22 +189,22 @@ export default class Map extends PureComponent { {showSelectStartOrEnd &&
- {lastClickedLabel &&

{lastClickedLabel}

} + {lastClickedLabel && +

+ {lastClickedLabel} +

} {markers.length > 0 && } {markers.length > 0 && }
@@ -209,6 +214,21 @@ export default class Map extends PureComponent { } } +function Isochrone ({isochrone, color}) { + return ( + + ) +} + class MapboxGeoJson extends GeoJson { componentWillMount () { const {mapbox} = require('mapbox.js') diff --git a/src/components/route-card.js b/src/components/route-card.js index 3fd0976..ad404ac 100644 --- a/src/components/route-card.js +++ b/src/components/route-card.js @@ -84,13 +84,15 @@ function TripDiff ({oldTravelTime, travelTime}) { if (oldTravelTime === 255) { return ( - {messages.NewTrip}
+ {messages.NewTrip} +
) } else if (actualDiff > 0) { return ( - {diff}%
+ {diff}% +
) } else { @@ -109,8 +111,12 @@ function Journeys ({journeys, oldTravelTime, travelTime, waitTime}) { if (!travelTime || !journeys) { return (
-
{messages.Systems.TripsTitle}
-
{messages.Systems.SelectEnd}
+
+ {messages.Systems.TripsTitle} +
+
+ {messages.Systems.SelectEnd} +
) } @@ -118,8 +124,12 @@ function Journeys ({journeys, oldTravelTime, travelTime, waitTime}) { if (travelTime === 255 || journeys.length === 0) { return (
-
{messages.Systems.TripsTitle}
-
{messages.Systems.TripsEmpty}
+
+ {messages.Systems.TripsTitle} +
+
+ {messages.Systems.TripsEmpty} +
) } @@ -128,19 +138,20 @@ function Journeys ({journeys, oldTravelTime, travelTime, waitTime}) { return (
-
{messages.Systems.BestTripTitle}
+
+ {messages.Systems.BestTripTitle} +
-
{travelTime} {messages.Units.Mins}
+
+ {travelTime} {messages.Units.Mins} +
{oldTravelTime && oldTravelTime !== travelTime && }
- {waitTime} - {' '} - {messages.Units.Mins} - {' '} + {waitTime} {messages.Units.Mins}{' '} {messages.Systems.Waiting}
@@ -151,11 +162,15 @@ function Journeys ({journeys, oldTravelTime, travelTime, waitTime}) {
{journeys.length > 1 &&
-
{messages.Systems.AlternateTripsTitle}
+
+ {messages.Systems.AlternateTripsTitle} +
{alternateJourneys.map((segments, jindex) => (
- {jindex + 1}. + + {jindex + 1}. + {segments.map((segment, index) => ( ))} @@ -204,16 +219,21 @@ function ShowAccess ({ }) { return (
-
{messages.Systems.AccessTitle}
+
+ {messages.Systems.AccessTitle} +
{base === ACCESSIBILITY_IS_EMPTY - ? {messages.Systems.SelectStart} + ? + {messages.Systems.SelectStart} + : base === ACCESSIBILITY_IS_LOADING - ? {messages.Systems.CalculatingAccessibility} + ? + {messages.Systems.CalculatingAccessibility} + : keys.map((k, i) => (
- {(base[k] | 0).toLocaleString()} - {' '} + {(base[k] | 0).toLocaleString()} {' '} {toSpaceCase(k)}
))} @@ -248,16 +268,21 @@ function AccessDiffPercentage ({newAccess, originalAccess}) { function ShowDiff ({keys, base, comparison}) { return (
-
{messages.Systems.AccessTitle}
+
+ {messages.Systems.AccessTitle} +
{base === ACCESSIBILITY_IS_EMPTY - ? {messages.Systems.SelectStart} + ? + {messages.Systems.SelectStart} + : base === ACCESSIBILITY_IS_LOADING - ? {messages.Systems.CalculatingAccessibility} + ? + {messages.Systems.CalculatingAccessibility} + : keys.map((key, i) => (
- {(base[key] | 0).toLocaleString()} - {' '} + {(base[key] | 0).toLocaleString()} {' '} {toSpaceCase(key)} .CardTitle { cursor: inherit; } diff --git a/src/index.js b/src/index.js index 1bab882..94b9a04 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,12 @@ import mount from '@conveyal/woonerf/mount' import Application from './containers/application' import reducers from './reducers' +import messages from './utils/messages' +// Set the title +document.title = messages.Title + +// Mount the app mount({ app: Application, reducers diff --git a/src/types.js b/src/types.js index b300a08..4f4b384 100644 --- a/src/types.js +++ b/src/types.js @@ -128,6 +128,7 @@ export type InputEvent = Event & { export type MapEvent = { latlng?: Coordinate, target: { - _latlng: Coordinate + _latlng: Coordinate, + _zoom: number } }