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 32.12  Getting a GoogleMap (LocatrFragment.java)

public class LocatrFragment extends SupportMapFragment {
    private static final String TAG = "LocatrFragment";

    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()) ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition 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.