React native 反应本地谷歌地图

React native 反应本地谷歌地图,react-native,google-maps,React Native,Google Maps,在我的react原生应用程序中。一旦用户在我的应用程序中按下按钮,我想打开标准的Google地图应用程序并显示特定位置。我如何才能做到这一点解决方案 相应地传递纬度和经度 或者,如果要使用自定义标签,请尝试以下操作: const scheme = Platform.select({ ios: 'maps:0,0?q=', android: 'geo:0,0?q=' }); const latLng = `${lat},${lng}`; const label = 'Custom Label';

在我的react原生应用程序中。一旦用户在我的应用程序中按下按钮,我想打开标准的Google地图应用程序并显示特定位置。我如何才能做到这一点

解决方案

相应地传递纬度和经度

或者,如果要使用自定义标签,请尝试以下操作:

const scheme = Platform.select({ ios: 'maps:0,0?q=', android: 'geo:0,0?q=' });
const latLng = `${lat},${lng}`;
const label = 'Custom Label';
const url = Platform.select({
  ios: `${scheme}${label}@${latLng}`,
  android: `${scheme}${latLng}(${label})`
});


Linking.openURL(url);

安装“react native navigation directions”并使用下面给出的代码。 call callShowDirections点击按钮,它会将您重定向到标准的谷歌地图应用程序

import { OpenMapDirections } from 'react-native-navigation-directions';

//Use this function 
  _callShowDirections = () => {
     const startPoint = {
       longitude: 'START_POINT_LONGITUDE',
       latitude: 'START_POINT_LATITUDE'
     } 

     const endPoint = {
       longitude: 'END_POINT_LONGITUDE',
       latitude:  'END_POINT_LATITUDE'
     }

    const transportPlan = 'd';

    OpenMapDirections(startPoint, endPoint, transportPlan).then(res => {
      console.log(res)
    });
  }

这回答了你的问题吗?
import { OpenMapDirections } from 'react-native-navigation-directions';

//Use this function 
  _callShowDirections = () => {
     const startPoint = {
       longitude: 'START_POINT_LONGITUDE',
       latitude: 'START_POINT_LATITUDE'
     } 

     const endPoint = {
       longitude: 'END_POINT_LONGITUDE',
       latitude:  'END_POINT_LATITUDE'
     }

    const transportPlan = 'd';

    OpenMapDirections(startPoint, endPoint, transportPlan).then(res => {
      console.log(res)
    });
  }