-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
executable file
·86 lines (82 loc) · 1.94 KB
/
App.js
File metadata and controls
executable file
·86 lines (82 loc) · 1.94 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
import * as React from 'react';
import {
Text,
View,
StyleSheet,
TouchableOpacity,
TextInput,
} from 'react-native';
import Geocode from 'react-native-geocode';
const App = () => {
const [input, setInput] = React.useState();
const [location, setLocation] = React.useState();
React.useEffect(() => {
Geocode.intialize('GMAPS-KEY', {
language: 'it',
});
}, []);
const pushedButton = () => {
Geocode.from('Via Garigliano, 28 Mestre 30173')
.then(json => {
var geo_location = json.results[0].geometry.location;
console.log(geo_location);
setLocation(geo_location);
})
.catch(error => console.warn(error));
};
return (
<View style={styles.container}>
<Text style={styles.paragraph}>Geocode example</Text>
<TextInput
style={styles.textInput}
placeholder={'Input the street here'}
onChangeText={text => setInput(text)}
value={input}
placeholderTextColor={'darkblue'}
/>
<TouchableOpacity onPress={pushedButton} style={styles.button}>
<Text style={[styles.paragraph, { color: 'white' }]}>Gecode me!</Text>
</TouchableOpacity>
{location && (
<Text style={styles.renderedText}>
Lat: {location.lat}
{'\n'}
Lng: {location.lng}
</Text>
)}
</View>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
padding: 8,
marginHorizontal: 40,
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
button: {
borderRadius: 10,
backgroundColor: 'darkblue',
},
textInput: {
borderRadius: 10,
backgroundColor: '#ddd',
color: 'darkblue',
padding: 18,
marginBottom: 20,
},
renderedText: {
color: 'darkblue',
fontSize: 22,
fontWeight: '700',
marginVertical: 20,
textAlign: 'center',
},
});