-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNavigationScreen.js
108 lines (102 loc) · 2.36 KB
/
NavigationScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import React from 'react';
import MapView from 'react-native-maps';
import {
Platform,
Button,
StyleSheet,
Text,
View,
Alert,
TouchableOpacity,
Dimensions
} from "react-native";
export default class NavigationScreen extends React.Component {
static navigationOptions = {
title: 'Tech Recycle Centers',
};
state = {
location: null
};
constructor(props) {
super(props);
this.state = {
location: {},
};
}
componentWillMount(){
navigator.geolocation.getCurrentPosition(
position => {
const data = JSON.stringify(position);
console.log(data);
this.setState({
location: data
});
},
error => Alert.alert(error.message),
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
);
}
render() {
var markers = [
{
latitude: 40.742220,
longitude: -73.980970,
title: "Garbage disposal, Waste management & recycling",
description: "waste management service\n 0.2 mil",
},
{
latitude: 40.740429,
longitude:-73.983910,
title: "The Junkluggers",
description: "Garbage collection service\n 1.6 mil",
}
]
return (
<View style={styles.container}>
<MapView style = {styles.mapStyle}
initialRegion={{
latitude: 40.7408711,
longitude: -73.9827362,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
>
<MapView.Marker
coordinate={{
longitude:markers[0].longitude,
latitude:markers[0].latitude
}}
title= {markers[0].title}
description={markers[0].description}
/>
<MapView.Marker
coordinate={{
longitude:markers[1].longitude,
latitude:markers[1].latitude
}}
title= {markers[1].title}
description={markers[1].description}
/>
</MapView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
marker: {
width: 8,
height: 8,
borderRadius: 4,
backgroundColor: "rgba(130,4,150, 0.9)",
},
mapStyle: {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
},
});