You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用android_intent_plus包指定谷歌地图导航的地图类型

问题解答

1. Google Maps导航URL(dir接口)不支持指定地图类型

你当前使用的https://www.google.com/maps/dir/是Google Maps的导航专用URL,官方并未提供参数来强制指定地图显示类型(默认/地形/卫星)。导航模式下的地图类型会遵循用户Google Maps APP的默认设置,无法通过该URL的参数修改。

2. 替代实现方法:使用Google Maps Intent深层链接

直接通过Android Intent调用Google Maps APP,利用其内部的extra参数可以指定地图类型,同时触发导航。具体代码修改如下:

if (Platform.isAndroid) {
  AndroidIntent intent = AndroidIntent(
    package: 'com.google.android.apps.maps', // 指定打开谷歌地图APP
    action: 'android.intent.action.VIEW',
    // geo URI格式:起点+终点+出行模式(d=driving代表驾车)
    data: 'geo:${appState.position.latitude},${appState.position.longitude}?q=${riderLocation.latitude},${riderLocation.longitude}&mode=d',
    extras: {
      'mapType': 2, // 地图类型参数:1=默认矢量地图,2=地形地图,3=卫星地图
      'navigation': 'true', // 直接启动导航,无需用户手动触发
    },
  );
  await intent.launch();
}

参数说明:

  • mapType取值对应:
    • 1:默认矢量地图
    • 2:地形地图
    • 3:卫星地图
  • navigation: 'true':确保打开APP后直接进入导航流程,省去用户手动点击"开始导航"的步骤

这种方式绕过了HTTP URL的限制,直接与Google Maps APP的Intent交互,能稳定实现指定地图类型的导航需求。

内容的提问来源于stack exchange,提问作者ayush

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 08:45:37