-
Notifications
You must be signed in to change notification settings - Fork 0
/
Maps.js
73 lines (65 loc) · 1.8 KB
/
Maps.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
//imports
import React from 'react';
import MapView from 'react-native-maps';
import { StyleSheet, Text, View, Dimensions } from 'react-native';
import MapViewDirections from 'react-native-maps-directions';
//declare
const { width, height } = Dimensions.get('window');
//const origin = {latitude: 37.3318456, longitude: -122.0296002};
//const destination = {latitude: 37.771707, longitude: -122.4053769};
const GOOGLE_MAPS_APIKEY = 'AIzaSyBbPSKOHDvHPOZMa_txPfKU0AcC9En23Vg';
const initialRegion = {
latitude: 1.3098,
longitude: 103.7775,
latitudeDelta: 0.005,
longitudeDelta: 0.005,
}
class Maps extends React.Component{
render(){
return(
<View style ={styles.container}>
//mapview create
<MapView
style = {styles.map}
zoomEnabled={true}
initialRegion={initialRegion}>
<MapViewDirections
origin={{latitude: 1.3098,
longitude: 103.7775}}
destination={{latitude: 1.3236,
longitude: 103.9273}}
apikey={GOOGLE_MAPS_APIKEY}
strokeWidth={500}
strokeColor="red"
/>
//create markers
<MapView.Marker
coordinate={{latitude: 1.3098,
longitude: 103.7775}}
title={"title"}
description={"description"}
/>
<MapView.Marker
coordinate={{latitude: 1.3236,
longitude: 103.9273}}
title={"title"}
description={"description"}
/>
</MapView>
</View>
)
}
}
export default Maps;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
map: {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
},
});