Join David Gassner for an in-depth discussion in this video Customizing marker icon graphics, part of Building Mobile Apps with Google Maps Android API v2.
When you add a marker to a Google map, by default you're using a reddish icon.…It looks just like the icons that are used in the browser versions of Google Maps.…But you can change the color of that icon or you can use your own custom graphics.…And I'll show you how to do both.…I'm working in a version of the project called Custom Markers.…I've refactored and moved around some of the code here.…Now, all of the code that's…needed to add the marker is in a new…method called setMarker at the bottom of the class.…
It receives three arguments, a string for the locality and a latitude and longitude.…And then it uses the title and position…methods of MarkerOptions to create and place the marker.…If there's an existing marker, it's removed.…I'm going to modify this code to change the color of the default marker.…First…I'll place the cursor after the existing method position and before the semicolon…and I'll add a new line of code, and call the icon method.…The icon method takes a BitmapDescriptor object, and you create…
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?