-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
78 lines (74 loc) · 2.01 KB
/
App.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
import React, {useState} from 'react';
import {Text, View, SafeAreaView} from 'react-native';
import RNMapView, {Marker, PROVIDER_GOOGLE} from 'react-native-maps';
import {StyleSheet} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
const App = () => {
const [latitude, setLatitude] = useState();
const [longitude, setLongitude] = useState();
const getCoordinates = e => {
setLatitude(e.latitude);
setLongitude(e.longitude);
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.container}>
<RNMapView
onLongPress={_ => {
console.log(_.nativeEvent.coordinate);
}}
// onPress={() => console.log('map pressed')}
// showsUserLocation={true}
// followsUserLocation={true}
// showsMyLocationButton={true}
showsCompass={true}
zoomEnabled={true}
provider={PROVIDER_GOOGLE}
scrollEnabled={true}
style={styles.mapView}
initialRegion={{
latitude: 28.652031,
longitude: 77.214785,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
onRegionChangeComplete={e => getCoordinates(e)}
/>
<Icon name="map-marker" size={40} style={styles.mapIcon} />
<View style={styles.bottomView}>
<Text style={styles.text}>{latitude}</Text>
<Text style={styles.text}>{longitude}</Text>
</View>
</View>
</SafeAreaView>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
},
mapView: {
flex: 1,
},
mapIcon: {
position: 'absolute',
top: '50%',
alignSelf: 'center',
color: 'black',
},
bottomView: {
paddingVertical: 10,
paddingHorizontal: 10,
backgroundColor: 'white',
position: 'absolute',
bottom: 10,
alignSelf: 'baseline',
alignSelf: 'center',
},
text: {
alignSelf: 'center',
color: 'black',
paddingVertical: 2,
},
});