Android Google Map Street View Example

In this tutorial, we’ll be implementing the StreetView feature of Google Maps in our Android Application.

To integrate Google Maps API in your application follow this tutorial.

Google Map StreetView

As the name says, Street View provides a view of the street. Instead of seeing the location’s pin on the road, with a StreetView you can an image of the entire Street!

Google Street View provides panoramic 360-degree views of the location. Street View is available with Google Maps v2 in Android.

To view Street View in your application you need to use the StreetViewPanorama class.
StreetViewPanorama is responsible for displaying the 360-degree panoramic image with the viewer(you) at the center of the sphere.

To integrate Street View in your application you need to use add the fragment StreetViewPanoramaFragment in your XML layout.

SupportStreetViewPanoramaFragment is used in place of StreetViewPanoramaFragment to support backward compatibility.

To load Google Maps Street View in your application you need to implement the interface : OnStreetViewPanoramaReadyCallback.

The method onStreetViewPanoramaReady gets triggered. In this method we set the following properties on the StreetViewPanaroma instance:

  • setPosition – We pass the LatLang here. Optionally we can pass a constant StreetViewSource.OUTDOOR to view the outdoor view of the location(on the street) instead of the inside view.
  • setStreetNamesEnabled(boolean) – Enabling this would show the street name (if it exists) on the panoramic image.
  • setUserNavigationEnabled(boolean) – Enabling this allows the user to navigate to different panoramas by clicking on the navigation links.
  • setPanningGesturesEnabled() and setZoomGesturesEnabled() allow us to change the camera angles and zoom into the streets respectively.

To get the current location in the Street View we do: streetViewPanorama.getLocation().position.

getLocation() returns a StreetViewPanoramaLocation instance. On this instance we can retrieve the properties links.

Links is basically an array of all the panoramic images connected to the current one.

Street View Panorama Listeners

We can add listener events on the StreetViewPanaroma instance :

  • OnStreetViewPanoramaChangeListener
  • OnStreetViewPanoramaCameraChangeListener
  • OnStreetViewPanoramaClickListener


Inside the method, we can add any custom action such as disabling the zoom gestures when the orientation is tilted beyond a certain level.

In the next section, we’ll implement Google Maps Street View in our Android Application.

Getting Started


Add your own SHA-1 Key and generate the API key in the Google console.

Add the following meta-data in the Android Manifest.xml application tag :

Add the following permissions as well:

Add the following dependencies in your build.gradle file:

Now we are all set to implement Google Maps Street View in our Android Application.

Project Structure



The code for the activity_main.xml is given below:

We’ve added a FloatingActionButton which would toggle the StreetView Fragment to display a new location.

The code for the is given below:

We show two locations in the same place. One is indoor and the other is outdoor.
panoramaChangeListener gets triggered whenever the panorama image changes. It displays a Toast of the current position.

And the place is Lords! The mecca of Cricket. Relish it in the output below:

android googlemaps-streetview output

If the Street View displays a black screen that means either the place doesn’t have a panoramic image or there is no authorized image available.

This brings an end to this tutorial. You can download the project from the link below:

References : Google Documentation

By admin

Leave a Reply

%d bloggers like this: