Opening StreetView from my app at a specific location
Asked Answered
B

2

4

I'm trying to open the Google StreetView on Panorama mode from my Android app.

I really wanna open the Google StreetView and not Google Maps, because I wanna use it with a Virtual Reality application that uses a VR Glass, that uses stereo view and panorama mode. The panorama mode that I wanna is like that: https://youtu.be/3mQKGEnWxIw

The following code opens the StreetView app:

PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.street");
startActivity(intent);

But it opens on the default screen.

EDIT 1:

I discovered how to open the panorama Activity of the Street View. First I listed the available Activities from the application:

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);
    }

}

Then I used the Activity com.google.vr.app.StreetViewApp.StreetViewApp. I can launch StreetView Panorama Activity directly using this code:

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);
}

But I still don't know how to pass the locations parameters to StreetView. How can I do that?

I have tested using 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);

And using 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));

But no success. Does anyone know how to pass the location parameters to StreetView App on Panorama mode?

EDIT 2:

I discovered that if I use a Street View Highlighted link, or a featured location, it is possible to open Street View on Panorama mode, passing the URI Intent. I tested the following links:

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

More can be found here: https://www.google.com/streetview/

But still don't know how to pass a generic location.

Bernoulli answered 28/6, 2018 at 12:39 Comment(5)
Check also this: #39602229Bernoulli
It is working for me in panorama mode:- 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);Bubbler
@Bubbler thanks for the suggestion, but I need to open that on street view, because it has the panorama stereo (2 eyes). Your suggestion open the maps app on streetview mode, but is not on panorama mode. I need this mode: youtu.be/3mQKGEnWxIwBernoulli
I think for a view like this youtu.be/3mQKGEnWxIw you need a app like google cardboard. You can also develop an app for VR using Google's VR SDK: developers.google.com/vr/develop/android/get-started . You can also include streetViewPanaroma inside your app by using thisBubbler
@Bubbler Thanks for your suggestion, but how do I pass the panorama to the cardboard app?Bernoulli
S
0

Here's how you can open Google Street View with your passed coordinates:

(I just tested it and it works as expected)

private void openStreetView (double latitude, double longitude) {
    Uri gmmIntentUri = Uri.parse ("google.streetview:cbll=" + latitude + "," + longitude);

    Intent mapIntent = new Intent (Intent.ACTION_VIEW, gmmIntentUri);
    mapIntent.setPackage ("com.google.android.apps.maps");

    startActivity (mapIntent);
}

You were close! the mistake you made was you overriding the Uri with an incorrect one, on your third code snippet :)

Here are more details: https://developers.google.com/maps/documentation/urls/android-intents

Shenyang answered 4/7, 2018 at 16:45 Comment(5)
Thanks for the answer but it opens the google maps on the streetview mode. But not on panorama mode. I need that the street view moves right/left, top/bottom when I move the device. To do that is necessary to opens the streetview app.Bernoulli
@Bernoulli I'm not really sure about that, do you consider this i.imgur.com/64LGy5J.jpg to be "street mode" (screenshot taken from my phone)?Shenyang
I saw your picture. But to navigate throw the view you need to click on the side arrows or slide to the sides. I wanna navigate moving/turning the device.Bernoulli
@Bernoulli No. Clicking on the arrows is only if you wanna "advance" from your position , like walking. In order to have the 180° panoramic view you want, you just need to swipe the screen with your finger (1 finger required) to the sides or top/bottom and change the angle you're looking at.Shenyang
I understood, swiping the finger I can navigate throw de view. But I wanna navigate turning the mobile to the sides, like the street view panorama navigation. Look at this video: youtu.be/3mQKGEnWxIwBernoulli
C
0

The answer of Mehdi, was right but on this moment is outdated. Take a look at https://developers.google.com/maps/documentation/urls/get-started#street-view-action.

You can do it this way:

public void openStreetView(Context context, double latitude, double longitude) {
        // See: https://developers.google.com/maps/documentation/urls/get-started#street-view-action
        int pitch = 0;
        int fieldOfView = 90;
        int heading = 0;
        Uri uri = Uri.parse(String.format("https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=%s,%s&heading=%s&pitch=%s&fov=%s",
                  latitude,
                  longitude,
                  heading,
                  pitch,
                  fieldOfView));
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    context.startActivity(intent);
}
Coessential answered 19/2, 2023 at 14:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.