Skip to content

Instantly share code, notes, and snippets.

@pengrad
Created August 29, 2015 18:07
Show Gist options
  • Save pengrad/bfe2588a9730779db6fb to your computer and use it in GitHub Desktop.
Save pengrad/bfe2588a9730779db6fb to your computer and use it in GitHub Desktop.
Activity with StreetViewPanorama as View
package com.github.pengrad.testtest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback;
import com.google.android.gms.maps.StreetViewPanorama;
import com.google.android.gms.maps.StreetViewPanoramaView;
import com.google.android.gms.maps.model.LatLng;
public class MainActivity extends AppCompatActivity {
private StreetViewPanoramaView mStreetViewPanoramaView;
private StreetViewPanorama mPanorama;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapview);
setTitle("My Map");
mStreetViewPanoramaView = (StreetViewPanoramaView) findViewById(R.id.steet_view_panorama);
mStreetViewPanoramaView.onCreate(savedInstanceState);
mStreetViewPanoramaView.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
panorama.setPosition(new LatLng(55.758818, 37.620587));
mPanorama = panorama;
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
mStreetViewPanoramaView.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
mStreetViewPanoramaView.onResume();
}
@Override
protected void onPause() {
super.onPause();
mStreetViewPanoramaView.onPause();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mStreetViewPanoramaView.onLowMemory();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mStreetViewPanoramaView.onSaveInstanceState(outState);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment