Red Ghost
Red Ghost

Reputation: 322

Android: Show multiple street views (Google Maps Api)

I have an xml file called activity_collage.xml with 2 street view fragments - I would like both fragments to display the street view of a given location - So a total of 2 street views on the screen

Here's my code:

public class Collage extends ActionBarActivity implements OnStreetViewPanoramaReadyCallback {

StreetViewPanoramaFragment topLeft, topRight;

static final LatLng posOne = new LatLng(43.771925, -79.512460);

static final LatLng posTwo = new LatLng(43.790634, -79.193632); 

Here's where I initialize my 2 StreetViewFragment objects in my onCreate() method

topLeft =
            (StreetViewPanoramaFragment) getFragmentManager()
                    .findFragmentById(R.id.picTL);
    topLeft.getStreetViewPanoramaAsync(this);

    topRight =
            (StreetViewPanoramaFragment) getFragmentManager()
                    .findFragmentById(R.id.picTR);

Here's the overridden method from the OnStreetViewPanoramaReadyCallback interface ...

@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
    panorama.setPosition(posOne);


}

But how do I set the street view for topRight?

Upvotes: 1

Views: 726

Answers (2)

CAZ
CAZ

Reputation: 119

I have the same problem with my fragment XML containing 2 fragments : map fragment, and StreetViewPanoramaFragment. StreetView stays blank. I managed to use it with a simple view instead of fragment.

With Kotlin it gives :

val myFrag=getView()!!.findViewById<StreetViewPanoramaView>(R.id.street_view_panorama)
    myFrag.onCreate(savedInstanceState);
    myFrag.getStreetViewPanoramaAsync(OnStreetViewPanoramaReadyCallback { panorama ->
        panorama.setPosition(LatLng(55.758818, 37.620587))
        svPano = panorama
    })

Upvotes: 0

Matthew Moss
Matthew Moss

Reputation: 11

According to http://code.google.com/p/gmaps-api-issues/issues/detail?id=6953, multiple StreetViewPanorama Objects are not supported. In my experience, no explicit errors occur, but the second StreetViewPanorama will remain blank.

Frustratingly, I don't think the documentation was updated like the above thread indicates it should have been.

Upvotes: 1

Related Questions