Showing the User’s Location on a Map
With the requirements behind you, now it is time to enjoy the fruits of your labor and show the user a map. The Maps API includes MapFragment and SupportMapFragment that you can subclass to conveniently handle the work of setting up the MapView and its associated model object, GoogleMap.
Create RunMapFragment, a subclass of SupportMapFragment, in a new file using the code below.
Listing 36.2 Basic RunMapFragment
(RunMapFragment.java
)
public class RunMapFragment extends SupportMapFragment { private static final String ARG_RUN_ID = "RUN_ID"; private GoogleMap mGoogleMap; public static RunMapFragment newInstance(long runId) { Bundle args = new Bundle(); args.putLong(ARG_RUN_ID, runId); RunMapFragment rf = new ...
Get Android Programming: The Big Nerd Ranch Guide 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.