【发布时间】:2018-01-13 14:48:28
【问题描述】:
我试图让我的按钮 onPress 函数调用一个函数,该函数将根据设备打开苹果地图或谷歌地图。由于某种原因,当我按下按钮时什么都没有发生。
这是我的功能:
openMap= () => {
console.log('open directions')
Platform.select({
ios: () => {
Linking.openURL('http://maps.apple.com/maps?daddr=');
},
android: () => {
Linking.openURL('http://maps.google.com/maps?daddr=');
}
});
}
这是按钮:
<TouchableOpacity
onPress={this.openMap}
style={styles.navigateBtn}>
<Icon name="md-navigate" style={{ fontSize: 24 }} />
<Text
style={{ fontSize: 13, fontWeight: "700", lineHeight: 14 }}
>
NAVIGATE
</Text>
</TouchableOpacity>
最终我想将经度和纬度传递给 openMap 函数以获取方向,但首先我需要打开地图。
这是我的导入
import { View, TouchableOpacity, Modal, Platform, Alert, StyleSheet, Linking } from "react-native";
import {Header, Content, Text, Button, Icon, Card,CardItem, Title, Left, Right, Body, Container
} from "native-base";
import { Constants } from 'expo
【问题讨论】:
标签: google-maps react-native deep-linking apple-maps