-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplace_map.js
More file actions
66 lines (62 loc) · 1.37 KB
/
place_map.js
File metadata and controls
66 lines (62 loc) · 1.37 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
import React, { Component } from 'react';
import {
AlertIOS,
Text,
MapView,
View,
TouchableHighlight,
StyleSheet,
Linking
} from 'react-native';
export default class PlaceMap extends Component {
constructor(props) {
super(props);
this.region = {
latitude: 46.773181,
longitude: 23.62094400000001,
latitudeDelta: 0.2,
longitudeDelta: 0.2,
title: "White House"
}
}
handleNavigation(la, lo) {
const rla = this.region.latitude;
const rlo = this.region.longitude;
const url = `http://maps.apple.com/?saddr=${rla},${rlo}&daddr=${la},${lo}&dirflg=d`;
return Linking.openURL(url);
}
render() {
const { annotations } = this.props;
annotations.forEach(annotation => {
annotation.rightCalloutView = (
<TouchableHighlight
style={styles.button}
onPress={this.handleNavigation.bind(this, annotation.latitude, annotation.longitude)}
>
<Text style={styles.buttonText}>Navigation</Text>
</TouchableHighlight>
);
})
return (
<MapView
style={styles.map}
region={this.region}
annotations={annotations}
/>
);
}
}
const styles = StyleSheet.create({
map: {
flex: 1
},
button: {
backgroundColor: 'red',
padding: 5,
margin: 5
},
buttonText: {
fontSize: 12,
color: 'white'
}
});