我在 iOS 上使用 RN 0.20。我想创建一个链接,如果您单击该链接,它会将您重定向到手机中可用的 map 应用程序及其坐标。这是我使用链接组件所做的。
redirectToMap() {
Linking.canOpenURL('geo:37.484847,-122.148386').then(supported => {
if (supported) {
Linking.openURL('geo:37.484847,-122.148386');
} else {
console.log('Don\'t know how to go');
}
}).catch(err => console.error('An error occurred', err));
}
但它一直给我“不知道怎么走”。但是,我从其文档中看到 https://facebook.github.io/react-native/docs/linking.html可以使用 geo:
链接到 map 。
最佳答案
使用正确的 URL 方案
看看 official documentation的iOS。 要打开 map ,请使用建议的方案:
http://maps.apple.com/?ll=<lat>,<long>
关于ios - 在 React Native 中链接 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35967139/