Join David Gassner for an in-depth discussion in this video Setting a map's initial state in the layout, part of Building Mobile Apps with Google Maps Android API v2.
As I previously described, the map displays initially at a location just…West of Africa at the intersection of the Equator and the Prime Meridian.…It also has a default zoom, bearing which is the rotation and tilt level.…You have complete control of this as the programmer, and you…can adjust the state of the map before it becomes visible.…Either with XML notation in the layout file or…programmatically with Java. And I'll start with the XML version.…This is what the application currently looks like when it opens up, but I…want to change it, so that it shows a location in New York City.…
To do this, I'll go to the Layout file.…I'm working in a version of the project called InitialStateXML.…When you declare the fragment or the map view, you always add this XML namespace,…with the namespace prefix of map.…We're now going to use that prefix to set certain attributes of…the map and the first attributes I'll set are the latitude and longitude.…You need to know what your latitude and longitude are going to…be and I will show you a really easy way of getting there.…
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?