Skip to content

Commit

Permalink
Implement google maps API for directions to restaurants
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbooorn committed Jun 11, 2017
1 parent 57c64f6 commit cb75fde
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
41 changes: 34 additions & 7 deletions components/result_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { StackNavigator } from 'react-navigation';
import { Text, View, StyleSheet, Image } from 'react-native';
import Button from 'apsl-react-native-button';
import { RideRequestButton } from 'react-native-uber-rides';
import getDirections from 'react-native-google-maps-directions'

const RATING = {
0: require('../assets/yelp_stars/web_and_ios/regular/regular_0.png'),
Expand All @@ -29,6 +30,7 @@ class ResultScreen extends React.Component{

this.handleNext = this.handleNext.bind(this);
this.handleResearch = this.handleResearch.bind(this);
this.handleGetDirections = this.handleGetDirections.bind(this);
}

componentDidMount(){
Expand All @@ -54,8 +56,28 @@ class ResultScreen extends React.Component{
}

handleResearch(){
const { navigate } = this.props.navigation;
navigate('Search')
this.props.navigation.goBack();
}

handleGetDirections = (business) => {
const data = {
source: {
latitude: this.props.navigation.state.params.latitude,
longitude: this.props.navigation.state.params.longitude
},
destination: {
latitude: business.coordinates.latitude,
longitude: business.coordinates.longitude
},
params: [
{
key: "dirflg",
value: "w"
}
]
}

getDirections(data)
}

render(){
Expand Down Expand Up @@ -116,14 +138,14 @@ class ResultScreen extends React.Component{
</Image>
</View>

<RideRequestButton
style={styles.uber}
pickup={{latitude: this.props.navigation.state.params.latitude, longitude: this.props.navigation.state.params.longitude}}
dropoff={{latitude: showBusiness.coordinates.latitude, longitude: showBusiness.coordinates.longitude}} />
<Button onPress={() => this.handleGetDirections(showBusiness)}
style={styles.nextButton}>
<Text>Get Directions</Text>
</Button>

<Button onPress={this.handleNext}
style={styles.nextButton}>
<Text>Nahh</Text>
<Text>What Else Ya Got?</Text>
</Button>
</View>
);
Expand Down Expand Up @@ -235,3 +257,8 @@ const styles = StyleSheet.create({
bottom: 150
}
})

// <RideRequestButton
// style={styles.uber}
// pickup={{latitude: this.props.navigation.state.params.latitude, longitude: this.props.navigation.state.params.longitude}}
// dropoff={{latitude: showBusiness.coordinates.latitude, longitude: showBusiness.coordinates.longitude}} />
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"react": "16.0.0-alpha.6",
"react-native": "0.44.2",
"react-native-button": "^2.0.0",
"react-native-google-maps-directions": "^1.1.0",
"react-native-icon": "^0.2.10",
"react-native-modal-picker": "0.0.16",
"react-native-radio-buttons": "^0.14.0",
Expand Down

0 comments on commit cb75fde

Please sign in to comment.