React native 如何在react本机映射链接中添加参数或变量

React native 如何在react本机映射链接中添加参数或变量,react-native,expo,React Native,Expo,导出默认函数ViewData({route,navigation}){ const{email,id,rideID,Source,Dest}=route.params; 返回( 详细信息屏幕 otherParam:{JSON.stringify(电子邮件)} otherParam:{JSON.stringify(id)} 其他参数:{JSON.stringify(rideID)} Linking.openURL(“google.navigation:q=“+{Source})} > 单击此处导航

导出默认函数ViewData({route,navigation}){
const{email,id,rideID,Source,Dest}=route.params;
返回(
详细信息屏幕
otherParam:{JSON.stringify(电子邮件)}
otherParam:{JSON.stringify(id)}
其他参数:{JSON.stringify(rideID)}
Linking.openURL(“google.navigation:q=“+{Source})}
>
单击此处导航到客户
{Source}
);

}
我使用这个函数,它对我有效

首先
从'react native'导入{Platform,Linking}

此功能在android中打开谷歌地图并在ios中打开苹果地图

const openMapApp = (latitude, longitude) => {
    if (Platform.OS === 'android') {
        Linking.openURL(`google.navigation:q=${latitude},${longitude}`);
    }else{
        Linking.openURL(`http://maps.apple.com/?daddr=${latitude},${longitude}`)
    }
};
const openGoogleMapApp = (latitude, longitude) => {
    if (Platform.OS === 'android') {
        Linking.openURL(`google.navigation:q=${latitude},${longitude}`);
    }else{
        Linking.openURL(`https://www.google.com/maps/?daddr=${latitude},${longitude}`);
    }
};
此功能在android和ios中打开谷歌地图

const openMapApp = (latitude, longitude) => {
    if (Platform.OS === 'android') {
        Linking.openURL(`google.navigation:q=${latitude},${longitude}`);
    }else{
        Linking.openURL(`http://maps.apple.com/?daddr=${latitude},${longitude}`)
    }
};
const openGoogleMapApp = (latitude, longitude) => {
    if (Platform.OS === 'android') {
        Linking.openURL(`google.navigation:q=${latitude},${longitude}`);
    }else{
        Linking.openURL(`https://www.google.com/maps/?daddr=${latitude},${longitude}`);
    }
};

${lat and long}没有输出我的变量,我已经尝试过了。试试纬度,经度用逗号,而不是纬度经度用空格。我需要的参数或变量是$SourceonPress={()=>Linking.openURL(“google.navigation:q=“+{Source}”)谢谢,我得到了它。我不确定它以前为什么不工作。