Using Maps SDK for Android v3.1.0 BETA

Version 3.1.0 beta of the Maps SDK for Android is a new implementation with the same API surface as the previous version (all classes and methods remain the same), and some new features for you to try:

  • Maps customization
  • Marker collision handling
  • Polyline customization

This guide shows you how to use the new features.

Maps customization (beta)

cloud-based maps styling provides a variety of tools and features that let you more easily customize and manage how your maps are styled. Rather than styling your map in code using the Maps APIs and SDKs, you can manage and style your maps in the Google Cloud Console. For more information, see Android Map Customization Overview.

Marker collision handling (beta)

You can specify whether custom markers should override default basemap labels when there is a collision, and to indicate relative priority between custom markers. For more information, see Marker Collision Handling (Android).

Polyline Customization (beta)

There are now several new ways to customize the appearance of polylines:

  • Multicolored polylines set polyline segments to different colors.
  • Gradient polylines color a polyline using a gradient of two colors.
  • Stamped polylines style a polyline using repeating bitmaps.

Creating a multicolored polyline

You can use spans to individually color segments of a polyline, by creating StyleSpan objects, and adding them to PolylineOptions using the addSpan() or addSpans() methods. By default, each item in the array will set the color of the corresponding line segment.

Creating a gradient polyline

You can define a gradient by specifying two 32-bit alpha-red-green-blue (ARGB) integers, to specify the beginning and ending colors of the stroke. Set this property on the shape's options object by calling PolylineOptions.addSpan().

Creating a stamped polyline

You can set the appearance of a polyline to a repeating bitmap texture. To do this, create a StampStyle of TextureStyle, then set this property on the shape's options object by calling PolylineOptions.addSpan().

Import the beta-compatible utility library

If you are using the Google Maps Android API utility library, you will need to also update your project dependencies to replace the existing version with the beta-compatible version by doing the following:

  1. Import the beta-compatible util library in your build.gradle file:
    implementation 'com.google.maps.android:android-maps-utils-v3:1.3.1'
  2. Remove the following from your build.gradle to remove non-beta-compatible utility library:
    implementation 'com.google.maps.android:android-maps-utils:1.3.1'

Run the samples

The Google Samples repository on GitHub includes sample apps that demonstrate the use of the v3.1.0 Beta Maps SDK for Android.