我开发了一个车辆监控应用程序,它使用OSMDroid (开放街道地图)显示车辆位置等等。一切都很好。
然而,我试图做到这样,当你按下地图上的车辆时,它会自动打开谷歌地图,并使用车辆的GPS坐标,立即进入街景。
我不能在我的应用程序中使用Google,因为商业应用程序是不免费的(至少,我的老板告诉我,我不得不使用OSMDroid)。我这么说只是因为我不希望你的回答是“只使用谷歌地图API”--我知道我可以,但我不能。
因此,解决方案是-将我的应用程序中的GPS信息发送给已经安装在平板电脑上的Google应用程序。
下面是我使用的代码:
@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?
这样做的代码是这样的:
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
这是我的新代码--这一次,我只得到一个持续加载的黑色屏幕:
@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;发布于 2017-09-25 14:17:30
// 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
https://stackoverflow.com/questions/46406937
复制相似问题