O'Reilly logo

Android Programming: The Big Nerd Ranch Guide, Third Edition by Kristin Marsicano, Chris Stewart, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with Your Map

Your SupportMapFragment creates a MapView, which is, in turn, a host for the object that does the real work: GoogleMap. So your first step is to acquire a reference to this master object. Do this by calling getMapAsync(OnMapReadyCallback).

Listing 34.9  Getting a GoogleMap (LocatrFragment.java)

public class LocatrFragment extends SupportMapFragment {
    ...
    private static final int REQUEST_LOCATION_PERMISSIONS = 0;

    private GoogleApiClient mClient;
    private GoogleMap mMap; private Bitmap mMapImage; private GalleryItem mMapItem; private Location mCurrentLocation; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); mClient = new GoogleApiClient.Builder(getActivity()) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required