从我的应用到Google地图应用直接进入街景模式
Go from my application to the Google Maps application directly into the street view mode
我开发了一个车辆监控应用程序,使用OSMDroid(Open Street Maps)来显示车辆位置等。一切正常。
不过,我正在努力做到这一点,当您在地图上按下车辆时,它会自动打开 Google 地图,并使用车辆的 GPS 坐标进入街景视图立即。
我不能在我的应用程序中使用 Google 地图,因为它对商业应用程序不是免费的(至少,我的老板告诉我,我必须使用 OSMDroid)。我这么说只是因为我不希望你的答案是 "just use the google maps 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;
}
一切正常,它转到 Google 地图应用程序并指向车辆的位置 - 问题是,我还没有找到任何方法自动进入那个特定的街景视图位置。
我在这里找到了答案:
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;
// 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
我开发了一个车辆监控应用程序,使用OSMDroid(Open Street Maps)来显示车辆位置等。一切正常。
不过,我正在努力做到这一点,当您在地图上按下车辆时,它会自动打开 Google 地图,并使用车辆的 GPS 坐标进入街景视图立即。
我不能在我的应用程序中使用 Google 地图,因为它对商业应用程序不是免费的(至少,我的老板告诉我,我必须使用 OSMDroid)。我这么说只是因为我不希望你的答案是 "just use the google maps 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;
}
一切正常,它转到 Google 地图应用程序并指向车辆的位置 - 问题是,我还没有找到任何方法自动进入那个特定的街景视图位置。
我在这里找到了答案:
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;
// 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