Implementing StreetViewPanoramaFragment

Until now, we have used MapFragment to integrate Google Maps with our application. However, to integrate street view with our application, we need to use StreetViewPanoramaFragment instead of MapFragment.

Add the following code to your main activity's layout file:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.StreetViewPanoramaFragment" />

activity_maps.xml

The android:name attribute in the earlier fragment specifies the StreetViewPanoramaFragment class to instantiate the layout. The android:id attribute defines ...

Get Learning Android Google Maps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.