Join David Gassner for an in-depth discussion in this video Displaying your first map, part of Building Mobile Apps with Google Maps Android API v2.
I am finally ready to display my FirstMap, I am working in a version of…the project now called FirstMap that already…has all the permissions and the API key.…If you've imported this project remember to set your API key in the metadata tag.…To display a map I'll add a new layout to the application.…I'll go to the Resources folder to the Layout folder, right-click…and choose New Android XML file. The resource type will be Layout…and I'll name this file activity_map.xml. And click Finish.…
The new layout starts with a root element of linear layout.…I'm going to change the linear layout to a fragment, because…I'm going to be presenting the map, using a fragment class.…Start by getting rid of this end tag, and putting in a slash right here.…And then, I'll change the linear layout to fragment, all lower-case.…Make sure you have this closing slash,…that will ensure that the element is complete.…Next, I'm going to add a new XML namespace declaration.…
I'll place that here above the layout width.…And…I'll expand this editor to full screen so I can see all the code.…
Note: An Android device with Android 3.0 (Honeycomb) or higher, and that has Google Play Store installed, is required to use the course exercises. (Kindle Fire and Nook devices do not qualify.) Finished mapping apps can be deployed on Android 2.2 (Froyo) or later.
- Setting up the developer tools
- Adding required permissions
- Getting a Google Maps API key
- Importing and linking the Google Play services
- Setting a map's initial state
- Geocoding an address
- Getting the current location programmatically
- Adding map markers
- Handling marker events
- Drawing lines, polygons, and circles
- Adding maps to existing apps
Skill Level Intermediate
Q: In the Chapter 2 movie "Checking the device for the Google Play services APK," when I create my first Google Maps app, the app crashes when I call the custom method servicesOK(). The error in LogCat starts with: "java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value." How do I fix this?