forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
126 lines (116 loc) · 3.09 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
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
var React = require('react-native');
var {
View,
StyleSheet,
TouchableOpacity,
ScrollView,
Text,
} = React;
var DisplayLatLng = require('./examples/DisplayLatLng');
var ViewsAsMarkers = require('./examples/ViewsAsMarkers');
var EventListener = require('./examples/EventListener');
var MarkerTypes = require('./examples/MarkerTypes');
var PolygonCreator = require('./examples/PolygonCreator');
var AnimatedViews = require('./examples/AnimatedViews');
var AnimatedMarkers = require('./examples/AnimatedMarkers');
var Callouts = require('./examples/Callouts');
var Overlays = require('./examples/Overlays');
var DefaultMarkers = require('./examples/DefaultMarkers');
var App = React.createClass({
getInitialState() {
return { Component: null };
},
renderExample([Component, title], i) {
return (
<TouchableOpacity
key={i}
style={styles.button}
onPress={() => this.setState({ Component })}
>
<Text>{title}</Text>
</TouchableOpacity>
);
},
renderBackButton() {
return (
<TouchableOpacity
style={styles.back}
onPress={() => this.setState({ Component: null })}
>
<Text style={{ fontWeight: 'bold', fontSize: 30 }}>←</Text>
</TouchableOpacity>
);
},
renderExamples(examples) {
var { Component } = this.state;
return (
<View style={styles.container}>
{Component && <Component />}
{Component && this.renderBackButton()}
{!Component && (
<ScrollView contentContainerStyle={styles.scrollview}>
{examples.map(this.renderExample)}
</ScrollView>
)}
</View>
);
},
render() {
return this.renderExamples([
[DisplayLatLng, 'Tracking Position'],
[ViewsAsMarkers, 'Arbitrary Views as Markers'],
[EventListener, 'Events'],
[MarkerTypes, 'Image Based Markers'],
[PolygonCreator, 'Polygon Creator'],
[AnimatedViews, 'Animating with MapViews'],
[AnimatedMarkers, 'Animated Marker Position'],
[Callouts, 'Custom Callouts'],
[Overlays, 'Circles, Polygons, and Polylines'],
[DefaultMarkers, 'Default Markers'],
]);
//return <DisplayLatLng />;
//return <ViewsAsMarkers />;
//return <EventListener />;
//return <MarkerTypes />;
//return <PolygonCreator />;
//return <AnimatedViews />;
//return <Callouts />;
//return <Overlays />;
//return <DefaultMarkers />;
},
});
var styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
scrollview: {
alignItems: 'center',
marginTop: 60,
},
button: {
flex: 1,
marginTop: 10,
backgroundColor: 'rgba(220,220,220,0.7)',
paddingHorizontal: 18,
paddingVertical: 12,
borderRadius: 20,
},
back: {
position: 'absolute',
top: 20,
left: 12,
backgroundColor: 'rgba(255,255,255,0.4)',
padding: 12,
borderRadius: 20,
width: 80,
alignItems: 'center',
justifyContent: 'center',
},
});
module.exports = App;