Skip to content

Commit afc9cbe

Browse files
Merge pull request #111 from conveyal/dev
v0.8.0
2 parents 2e06b88 + cdd4cd5 commit afc9cbe

File tree

11 files changed

+177
-76
lines changed

11 files changed

+177
-76
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
66

7-
<title>IndyConnect</title>
7+
<title>Conveyal Analysis</title>
88

99
<link href="assets/index.css" rel="stylesheet">
1010
</head>

src/actions/browsochrones.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
setEnd,
1818
setEndLabel,
1919
setStart,
20-
setStartLabel
20+
setStartLabel,
21+
updateMap
2122
} from '../actions'
2223

2324
import type {Store} from '../types'
@@ -42,8 +43,14 @@ export default function initialize ({
4243
),
4344
geocodeQs({geocoder, qs}).then(([start, end]) => {
4445
const actions = []
45-
if (start) actions.push(setStart(start))
46+
if (start) {
47+
actions.push(setStart(start))
48+
actions.push(
49+
updateMap({centerCoordinates: lonlat.toLeaflet(start.latlng)})
50+
)
51+
}
4652
if (end) actions.push(setEnd(end))
53+
if (qs.zoom) actions.push(updateMap({zoom: parseInt(qs.zoom, 10)}))
4754
actions.push(
4855
fetchGrids(browsochrones)
4956
.then(grids =>

src/components/application.js

+7-17
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,7 @@ export default class Application extends Component<void, Props, State> {
114114
return markers
115115
}
116116

117-
_setStart = ({
118-
label,
119-
latlng
120-
}: {
121-
label?: string,
122-
latlng: Coordinate
123-
}) => {
117+
_setStart = ({label, latlng}: {label?: string, latlng: Coordinate}) => {
124118
const {browsochrones, map, mapMarkers, timeCutoff, updateStart} = this.props
125119
const endLatlng = mapMarkers.end && mapMarkers.end.latlng
126120
? mapMarkers.end.latlng
@@ -153,13 +147,7 @@ export default class Application extends Component<void, Props, State> {
153147
}
154148
}
155149

156-
_setEnd = ({
157-
label,
158-
latlng
159-
}: {
160-
label?: string,
161-
latlng: Coordinate
162-
}) => {
150+
_setEnd = ({label, latlng}: {label?: string, latlng: Coordinate}) => {
163151
const {browsochrones, map, mapMarkers, updateEnd} = this.props
164152
updateEnd({
165153
browsochronesInstances: browsochrones.instances,
@@ -221,10 +209,10 @@ export default class Application extends Component<void, Props, State> {
221209
<div>
222210
<div className='Fullscreen'>
223211
<Map
212+
active={browsochrones.active}
224213
centerCoordinates={map.centerCoordinates}
225214
clearStartAndEnd={this._clearStartAndEnd}
226-
geojson={map.geojson}
227-
geojsonColor={browsochrones.active === 0 ? '#4269a4' : 'darkorange'}
215+
isochrones={map.isochrones}
228216
markers={markers}
229217
pointsOfInterest={pointsOfInterest}
230218
setEnd={this._setEnd}
@@ -275,7 +263,9 @@ export default class Application extends Component<void, Props, State> {
275263
actionLog &&
276264
actionLog.length > 0 &&
277265
<div className='Card'>
278-
<div className='CardTitle'>{messages.Log.Title}</div>
266+
<div className='CardTitle'>
267+
{messages.Log.Title}
268+
</div>
279269
<Log items={actionLog} />
280270
</div>}
281271
</div>

src/components/form.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export default ({
5050
start
5151
}: Props) => (
5252
<div>
53-
<div className='heading'>{messages.Geocoding.StartTitle}</div>
53+
<div className='heading'>
54+
{messages.Geocoding.StartTitle}
55+
</div>
5456
<div className='Geocoder'>
5557
<Geocoder
5658
apiKey={process.env.MAPZEN_SEARCH_KEY}
@@ -69,7 +71,9 @@ export default ({
6971
</div>
7072
{start &&
7173
<div>
72-
<div className='heading'>{messages.Geocoding.EndTitle}</div>
74+
<div className='heading'>
75+
{messages.Geocoding.EndTitle}
76+
</div>
7377
<div className='Geocoder'>
7478
<Geocoder
7579
apiKey={process.env.MAPZEN_SEARCH_KEY}

src/components/log-item/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export default (props: LogItem) => (
1111
<small className='LogItem-createdAt'>
1212
{formatDate(props.createdAt, FORMAT)}
1313
</small>
14-
<span className='LogItem-text'>{props.text}</span>
14+
<span className='LogItem-text'>
15+
{props.text}
16+
</span>
1517
</div>
1618
)

src/components/map.js

+46-26
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from 'react-leaflet'
1212

1313
import Icon from './icon'
14+
import {setKeyTo} from '../utils/hash'
1415
import leafletIcon from '../utils/leaflet-icons'
1516
import messages from '../utils/messages'
1617
import TransitiveLayer from './transitive-map-layer'
@@ -33,10 +34,10 @@ const endIcon = leafletIcon({
3334
})
3435

3536
type Props = {
37+
active: number,
3638
centerCoordinates: Coordinate,
3739
clearStartAndEnd(): void,
38-
geojson: Feature[],
39-
geojsonColor: string,
40+
isochrones: any[],
4041
markers: any[],
4142
pointsOfInterest: PointsOfInterest,
4243
setEnd(any): void,
@@ -107,11 +108,15 @@ export default class Map extends PureComponent<void, Props, State> {
107108
})
108109
}
109110

111+
_setZoom = (e: MapEvent) => {
112+
setKeyTo('zoom', e.target._zoom)
113+
}
114+
110115
render (): React$Element<LeafletMap> {
111116
const {
117+
active,
112118
centerCoordinates,
113-
geojson,
114-
geojsonColor,
119+
isochrones,
115120
markers,
116121
pointsOfInterest,
117122
transitive,
@@ -129,11 +134,15 @@ export default class Map extends PureComponent<void, Props, State> {
129134
tileLayerProps.zoomOffset = -1
130135
}
131136

137+
const baseIsochrone = isochrones[0]
138+
const comparisonIsochrone = active !== 0 ? isochrones[active] : null
139+
132140
return (
133141
<LeafletMap
134142
center={centerCoordinates}
135143
className='Taui-Map'
136144
ref='map'
145+
onZoomend={this._setZoom}
137146
zoom={zoom}
138147
onClick={this._onMapClick}
139148
preferCanvas
@@ -159,47 +168,43 @@ export default class Map extends PureComponent<void, Props, State> {
159168
onDragEnd={m.onDragEnd}
160169
position={m.position}
161170
>
162-
{m.label && <Popup><span>{m.label}</span></Popup>}
171+
{m.label &&
172+
<Popup>
173+
<span>
174+
{m.label}
175+
</span>
176+
</Popup>}
163177
</Marker>
164178
))}
165179

166-
{geojson.map(g => {
167-
return (
168-
<GeoJson
169-
key={`${g.key}`}
170-
data={g}
171-
style={{
172-
fillColor: geojsonColor,
173-
pointerEvents: 'none',
174-
stroke: geojsonColor,
175-
weight: 1
176-
}}
177-
/>
178-
)
179-
})}
180+
{baseIsochrone &&
181+
<Isochrone isochrone={baseIsochrone} color='#4269a4' />}
182+
183+
{comparisonIsochrone &&
184+
<Isochrone isochrone={comparisonIsochrone} color='darkorange' />}
180185

181186
{transitive &&
182187
<TransitiveLayer data={transitive} styles={transitiveStyle} />}
183188

184189
{showSelectStartOrEnd &&
185190
<Popup closeButton={false} position={lastClickedLatlng}>
186191
<div className='Popup'>
187-
{lastClickedLabel && <h3>{lastClickedLabel}</h3>}
192+
{lastClickedLabel &&
193+
<h3>
194+
{lastClickedLabel}
195+
</h3>}
188196
<button onClick={this._setStart}>
189-
<Icon type='map-marker' />
190-
{' '}
197+
<Icon type='map-marker' />{' '}
191198
{messages.Map.SetLocationPopup.SetStart}
192199
</button>
193200
{markers.length > 0 &&
194201
<button onClick={this._setEnd}>
195-
<Icon type='map-marker' />
196-
{' '}
202+
<Icon type='map-marker' />{' '}
197203
{messages.Map.SetLocationPopup.SetEnd}
198204
</button>}
199205
{markers.length > 0 &&
200206
<button onClick={this._clearStartAndEnd}>
201-
<Icon type='times' />
202-
{' '}
207+
<Icon type='times' />{' '}
203208
{messages.Map.SetLocationPopup.ClearMarkers}
204209
</button>}
205210
</div>
@@ -209,6 +214,21 @@ export default class Map extends PureComponent<void, Props, State> {
209214
}
210215
}
211216

217+
function Isochrone ({isochrone, color}) {
218+
return (
219+
<GeoJson
220+
key={`${isochrone.key}`}
221+
data={isochrone}
222+
style={{
223+
fillColor: color,
224+
pointerEvents: 'none',
225+
stroke: color,
226+
weight: 1
227+
}}
228+
/>
229+
)
230+
}
231+
212232
class MapboxGeoJson extends GeoJson {
213233
componentWillMount () {
214234
const {mapbox} = require('mapbox.js')

0 commit comments

Comments
 (0)