lundi 23 février 2015

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?




Aucun commentaire:

Enregistrer un commentaire