首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从我的应用程序转到Google应用程序,直接进入街道视图模式

从我的应用程序转到Google应用程序,直接进入街道视图模式
EN

Stack Overflow用户
提问于 2017-09-25 13:53:47
回答 1查看 402关注 0票数 0

我开发了一个车辆监控应用程序,它使用OSMDroid (开放街道地图)显示车辆位置等等。一切都很好。

然而,我试图做到这样,当你按下地图上的车辆时,它会自动打开谷歌地图,并使用车辆的GPS坐标,立即进入街景。

我不能在我的应用程序中使用Google,因为商业应用程序是不免费的(至少,我的老板告诉我,我不得不使用OSMDroid)。我这么说只是因为我不希望你的回答是“只使用谷歌地图API”--我知道我可以,但我不能。

因此,解决方案是-将我的应用程序中的GPS信息发送给已经安装在平板电脑上的Google应用程序。

下面是我使用的代码:

代码语言:javascript
复制
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
    //on a tap on the bus map indicator, go to google maps in the particular location of the bus
    Uri uri = Uri.parse("geo:"+gpsLatitude[0]+","+gpsLongitude[0]+"?z=" + map.getZoomLevel());
    //set the data for the intent as the created uri
    Intent intent = new Intent(Intent.ACTION_VIEW,uri);
    //go to the location of the bus
    startActivity(intent);

    return true;
}

一切都很好,它的谷歌地图应用程序,并指出了车辆的位置-问题是,我还没有找到任何方法,自动进入街景在那个特定的位置。

我在这里找到了一个答案:

How to open a street view in virtual reality mode programmatically?

这样做的代码是这样的:

代码语言:javascript
复制
Intent streetView = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("google.streetview:cbll=27.173891,78.042068" + "&cbp=1,90,,0,1.0&mz=8"));
startActivity(streetView);

然而,我不知道"&cpb“参数代表什么。

这里可能的答案是:https://productforums.google.com/forum/#!topic/maps/aBj7qc8j0BI

这是我的新代码--这一次,我只得到一个持续加载的黑色屏幕:

代码语言:javascript
复制
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
    //on a tap on the bus map indicator, go to street view in the particular location of the bus
    Uri googleMapsUri = Uri.parse("google.streetview:cbll="+gpsLatitude[0]+","+gpsLongitude[0]);
    //set the data for the intent as the created uri
    Intent mapIntent = new Intent(Intent.ACTION_VIEW,googleMapsUri);
    // specify the google maps package
    mapIntent.setPackage("com.google.android.apps.maps");
    //go to the location of the bus
    startActivity(mapIntent);

    return true;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-25 14:17:30

代码语言:javascript
复制
// Create a Uri from an intent string. Use the result to create an Intent.
Uri gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988");

// Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
// Make the Intent explicit by setting the Google Maps package
mapIntent.setPackage("com.google.android.apps.maps");

// Attempt to start an activity that can handle the Intent
startActivity(mapIntent);

https://developers.google.com/maps/documentation/urls/android-intents

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46406937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档