'Google maps' 导航应用

'Google maps' Navigation application

如何通过 android 或 ios flutter react-native 中的另一个 apk 打开 google 地图 apk .. 或任何移动技术。我想在我的应用程序中制作一个导航系统,所以我想通过我的应用程序直接使用 google 地图。有人可以帮我吗?

要从您的应用程序打开 Google 地图应用程序,您可以这样做。

  • 首先设置您的 url 字符串(您将发送到 Google 地图应用的内容,以便它知道给出的方向):

    String url = 'https://www.google.com/maps/dir/?api=1&origin=' +
          currentLocation.latitude.toString() +
          ',' +
          currentLocation.longitude.toString() +
          ' &destination=' +
          lat.toString() +
          ',' +
          lon.toString() +
          '&travelmode=driving&dir_action=navigate';
    
    _launchURL(url);
    

其中 currentLocation 表示用户当前位置,lat 和 lon 表示目的地。

  • 然后使用 url启动器启动 url:

    void _launchURL(String url) async {
      if (await canLaunch(url)) {
        await launch(url);
      } else {
        throw 'Could not launch $url';
      }
    }