import { Linking, Alert } from "react-native";
async function openWithGoogleMap() {
/** Google Map API offers different URL to deep link to various locatioon and map ressources.
* Check their docs - https://developers.google.com/maps/documentation/urls/get-started
*/
const url =
"https://www.google.com/maps/search/?api=1&query=47.5951518%2C-122.3316393";
const supported = await Linking.canOpenURL(url);
if (supported) {
// Opening the link with some app, if the URL scheme is "http" the web link should be opened
// by some browser in the mobile
await Linking.openURL(url);
} else {
Alert.alert(`Don't know how to open this URL: ${url}`);
}
}
1条答案
按热度按时间i2byvkas1#
GoogleMap提供跨平台深度链接通用URL。如果安装了本机GoogleMap应用程序,则将使用该应用程序打开,否则,使用用户设备上安装的默认Web浏览器。
您可以使用React Native Linking API动态链接到特定位置。