Join David Gassner for an in-depth discussion in this video Drawing circles, part of Building Mobile Apps with Google Maps Android API v2.
I've previously described how to draw lines and polygons.…And now I'll describe the third type of shape you can add to a map, a circle.…I'm working in a version of the project called drawing circles.…And in this project's main activity, I've declared a field…called Marker data typed as the Google Maps marker class.…This version of the app will allow only one marker at a time.…In the set marker method down here, I'm creating my marker options…object as before and then checking to see if the marker already exists.…
If it does, I remove it with the code in this method.…Remove everything and then I add the marker to the map.…My goal in this demo is to add a circle at the same time as I add the marker.…It will have the same center as the marker and…just add some visual emphasis to the display.…I'll start back at the top of the class by creating a new field data typed as circle.…After the marker field, I'll add a new field and I'll use the circle class.…
Be sure to add the import statement for that class, and I'll name it shape.…
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?