-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMap.js
More file actions
126 lines (122 loc) · 2.71 KB
/
Map.js
File metadata and controls
126 lines (122 loc) · 2.71 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React from 'react';
import MapView, { Marker, Callout } from 'react-native-maps';
import {
Dimensions,
SafeAreaView,
ScrollView,
View,
StyleSheet,
Text,
TouchableOpacity,
} from 'react-native';
export default function Map({navigation}) {
const [ pin, setPin ] = React.useState({
latitude: 30.284918,
longitude: -97.734055
})
const [ pin2, setPin2 ] = React.useState({
latitude: 30.685918,
longitude: -97.734055
})
const [ pin3, setPin3 ] = React.useState({
latitude: 30.384918,
longitude: -97.834055
})
const [region, setRegion] = React.useState({
latitude: 30.284918,
longitude: -97.734055,
latitudeDelta: 0.922,
longitudeDelta: 0.0421
})
return (
<View style={styles.container}>
<Text style={styles.title}>Dashboard</Text>
<MapView
initialRegion={region}
showsUserLocation={false}
showsCompass={true}
rotateEnabled={true}
style={styles.map}
>
<Marker
coordinate={pin}
pinColor="black"
draggable={true}
onDragStart={(e) => {
console.log("Drag start", e.nativeEvent.coordinates)
}}
onDragEnd={(e) => {
setPin({
latitude: 30.284918,
longitude: -97.734055
})
}}
>
<Callout>
<Text>Low</Text>
</Callout>
</Marker>
<Marker
coordinate={pin2}
pinColor="red"
draggable={true}
onDragStart={(f) => {
console.log("Drag start", f.nativeEvent.coordinates)
}}
onDragEnd={(f) => {
setPin2({
latitude: 35.284918,
longitude: -97.734055
})
}}
>
<Callout>
<Text>High</Text>
</Callout>
</Marker>
<Marker
coordinate={pin3}
pinColor="green"
draggable={true}
onDragStart={(f) => {
console.log("Drag start", f.nativeEvent.coordinates)
}}
onDragEnd={(f) => {
setPin3({
latitude: 35.284918,
longitude: -97.734055
})
}}
>
<Callout>
<Text>Medium</Text>
</Callout>
</Marker>
</MapView>
</View>
);
}
const styles = StyleSheet.create({
container: {
overflow: 'hidden',
height: Dimensions.get('window').height,
width: Dimensions.get('window').width,
backgroundColor: '#121212',
},
map: {
borderTopRightRadius: 20,
borderTopLeftRadius: 20,
top: 140,
left: 0,
right: 0,
bottom: 0,
position: 'absolute'
},
title: {
fontSize: 30,
fontWeight: '800',
textAlign: 'center',
marginTop: 80,
color: 'white',
}
});