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

如何通过Java Intent全屏打开Google Street View?

解决Google街景全屏打开问题

要直接全屏打开Google街景,你需要调整Intent的触发参数,以下是两种可行方案:

方案1:修改URI参数(无需额外依赖)

原URI仅定位到目标坐标,未指定进入全屏的指令。你可以在URI中添加cbp参数,强制跳过预览界面直接进入全屏街景:

String uri = String.format("google.streetview:cbll=%f,%f&cbp=1,99.9,,0,1.0", latitude, longitude);
Intent streetViewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
streetViewIntent.setPackage("com.google.android.apps.maps");
if (streetViewIntent.resolveActivity(getReactApplicationContext().getPackageManager()) != null) {
    streetViewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getReactApplicationContext().startActivity(streetViewIntent);
}

参数说明

cbp参数格式为cbp=<pitch>,<yaw>,<zoom>,<bearing>,<tilt>,其中:

  • 最后一个参数设为1.0会触发全屏模式
  • 前序参数可按需调整视角、朝向,示例值为通用全屏适配参数

方案2:使用Google Maps SDK专用Intent(更灵活)

如果URI参数方案不生效,可以依赖Google Play Services库,使用官方提供的街景专用Intent:

1. 添加依赖

在项目build.gradle中引入Maps SDK依赖:

implementation 'com.google.android.gms:play-services-maps:18.2.0'

2. 实现代码

import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.StreetViewPanoramaOptions;
import com.google.android.gms.maps.StreetViewPanoramaIntent;

LatLng targetLocation = new LatLng(latitude, longitude);
StreetViewPanoramaOptions options = new StreetViewPanoramaOptions()
    .position(targetLocation)
    .setPanningGesturesEnabled(true)
    .setZoomGesturesEnabled(true);

Intent streetViewIntent = StreetViewPanoramaIntent.createStreetViewPanoramaIntent(
    getReactApplicationContext(), options);
streetViewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getReactApplicationContext().startActivity(streetViewIntent);

该方案能精准控制街景启动状态,确保直接进入全屏模式。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 22:43:18