-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from "react-redux"; | ||
import { generateDirections } from '../actions'; | ||
import MapComponent from '../components/MapComponent'; | ||
import {geolocated} from 'react-geolocated'; | ||
|
||
class MapContainer extends Component { | ||
|
||
render() { | ||
return ( | ||
this.props.coords && ( | ||
<MapComponent | ||
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVb99HgTAxKCABiclsF0X7uzoLCN3JnLQ&v=3.exp&libraries=geometry,drawing,places" | ||
loadingElement={<div style={{ height: `100%` }} />} | ||
containerElement={<div style={{ height: `100%` }} />} | ||
mapElement={<div style={{ height: `88.5vh` }} />} | ||
generateDirections={this.props.generateDirections} | ||
directions={this.props.directions} | ||
coords={this.props.coords} | ||
/> | ||
) | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
directions: state.directionsReducer.directions, | ||
}; | ||
} | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
generateDirections: (google, coords) => dispatch(generateDirections(google, coords)) | ||
}; | ||
} | ||
|
||
export default geolocated({ | ||
positionOptions: { | ||
enableHighAccuracy: false, | ||
}, | ||
userDecisionTimeout: 5000, | ||
})(connect(mapStateToProps, mapDispatchToProps)(MapContainer)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const initialState = { | ||
directions: null, | ||
} | ||
|
||
export const directionsReducer = (state = initialState, action) => { | ||
switch(action.type) { | ||
case "GENERATE_DIRECTIONS": | ||
return {...state, directions: action.payload} | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { combineReducers } from 'redux'; | ||
import { userReducer } from './userReducer'; | ||
import { layoutReducer } from './layoutReducer'; | ||
import { directionsReducer } from './directionsReducer'; | ||
|
||
export default combineReducers({ | ||
userReducer, | ||
layoutReducer, | ||
directionsReducer | ||
}); |