Join David Gassner for an in-depth discussion in this video Setting a map's initial state programmatically, part of Building Mobile Apps with Google Maps Android API v2.
In a previous movie I described how to set…the initial state of a map using XML layout code.…I did this in a layout file, the activity map.xml file.…But in this project I've removed that code, and I'm now going to…show how to set the initial state of the map using Java code.…In this version of the application. I've added some constants.…They're double values, and…there are three pairs of latitudes and longitudes.…One for each of three cities, Seattle, Sydney, and New York.…
And I'll describe how to write the Java code to…turn these numeric values into something that can control the map.…Right now in this application if I run it, I'll start at the default map location.…At that point in the ocean just off of Africa.…So my job…is to add code to start off in New York, or Sydney, or Seattle.…I'll begin by creating a new method, that I'll…place at the bottom of the main activity class.…I'll make it private and return void. And I'll name the method go to location.…
The method will receive two arguments. Both of them double values.…
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?