【发布时间】:2018-06-28 12:39:25
【问题描述】:
我正在尝试从我的 Android 应用打开 Google 街景全景模式。
我真的想打开 Google StreetView 而不是 Google Maps,因为我想将它与使用 VR Glass 的虚拟现实应用程序一起使用,该应用程序使用立体视图和全景模式。我想要的全景模式是这样的:https://youtu.be/3mQKGEnWxIw
以下代码打开街景应用:
PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.street");
startActivity(intent);
但它会在默认屏幕上打开。
编辑 1:
我发现了如何打开街景的全景 Activity。首先,我列出了应用程序中可用的活动:
void listAppActivities(String packagename) {
PackageManager pManager = getPackageManager();
Intent startIntent = new Intent();
startIntent.setPackage(packagename);
List<ResolveInfo> activities = pManager.queryIntentActivities(startIntent, 0);
for (ResolveInfo ri : activities) {
System.out.println("getAppActivities::nome::" + ri.activityInfo.name);
}
}
然后我使用了 Activity com.google.vr.app.StreetViewApp.StreetViewApp。我可以使用以下代码直接启动 StreetView Panorama Activity:
void openStreetView() {
String packagename = "com.google.android.street";
PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(packagename);
intent.setComponent(new ComponentName(packagename, "com.google.vr.app.StreetViewApp.StreetViewApp"));
startActivity(intent);
}
但我仍然不知道如何将位置参数传递给 StreetView。我该怎么做?
我已经使用 URI 进行了测试:
Uri gmmIntentUri;
//gmmIntentUri = Uri.parse("geo:"+lat+","+lng); // Test1
gmmIntentUri = Uri.parse("google.streetview:cbll="+lat+","+lng); // Test2
//gmmIntentUri = Uri.parse("http://maps.google.com/maps?ll="+lat+","+lng); // Test3
intent.setData(gmmIntentUri);
并使用 Intent.putExtra:
intent.putExtra("cbll", lat+","+lng);
intent.putExtra("args", "cbll="+lat+","+lng);
intent.putExtra("lat", new Double(lat));
intent.putExtra("long", new Double(lng));
intent.putExtra("lng", new Double(lng));
但没有成功。有人知道如何在全景模式下将位置参数传递给街景应用吗?
编辑 2:
我发现,如果我使用 Street View Highlighted 链接或特色位置,则可以在全景模式下打开 Street View,并传递 URI Intent。我测试了以下链接:
https://www.google.com/streetview/#christmas-island/ethel-beach-2 https://www.google.com/streetview/#russian-landmarks/terskol-1 https://www.google.com/streetview/#day-of-the-dead-in-mexico/ofrenda-dia-de-muertos-zocalo
更多信息可以在这里找到: https://www.google.com/streetview/
但仍然不知道如何传递通用位置。
【问题讨论】:
-
它在全景模式下为我工作:- Uri gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent);
-
@Nainal 感谢您的建议,但我需要在街景上打开它,因为它有全景立体声(2 只眼睛)。您的建议在街景模式下打开地图应用程序,但不在全景模式下。我需要这种模式:youtu.be/3mQKGEnWxIw
-
我认为对于youtu.be/3mQKGEnWxIw 这样的视图,您需要像 google cardboard 这样的应用程序。您还可以使用 Google 的 VR SDK 开发 VR 应用:developers.google.com/vr/develop/android/get-started。您还可以使用 this 在您的应用中包含 streetViewPanaroma
-
@Nainal 感谢您的建议,但是如何将全景图传递给 Cardboard 应用程序?
标签: android google-maps google-street-view