As part of our ongoing efforts to enable developers to further style and customize the Google basemap, today we’re announcing the launch of advanced polyline styling for the Maps SDK for Android. This feature builds on the polylines capability we currently offer, which allows developers to create stylized lines rendered on the map, and are often used to represent information about directions, parade routes, and street closures. Polylines are one of the most common features Google Maps Platform developers use to customize maps for their users.
Advanced polyline styling gives you new ways to make this core feature more informational and expressive by introducing three new polyline customizations: multicolored polylines, gradient polylines, and stamped polylines.
Multicolored polylines allow you to segment polylines, and represent information by applying different colors to each segment. This customization type has many use cases, such as conveying varied information along a route, matching a company’s branding for a seasonal campaign, or drawing a user’s attention to an area.
To use a multicolored polyline, create `StyleSpan` objects and add 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. The following example shows setting segment colors to create a polyline with green and purple segments:
Gradient polylines apply a two-color gradient over the entire polyline, which can be useful for representing changing intensities, such as traffic flow or a change in elevation.
Here’s an example that creates a gradient polyline from San Francisco to Rancho Corral de Tierra:
With stamped polylines, you can create a polyline using a repeating bitmap image of your choice. This allows you to customize the shape and appearance of the polyline.
To use a stamped polyline, set the appearance of a polyline to a repeating bitmap texture by creating a `StampStyle` of `TextureStyle`. You can set this property on the shape’s options object by calling `PolylineOptions.addSpan()`:
Styling and customization features are one of the best and easiest ways to improve the mapping experience for your users, convey critical information, and make the map your own. Along with the recent release of other styling and customization features like Cloud-based maps styling, Data-driven styling, and WebGL-powered maps features, our team is working hard to give you the tools you need to create great mapping experiences that have the flexibility to meet your individual needs. We hope you enjoy this new way to customize and style polylines on your maps.
For more information on Google Maps Platform, visit our website.
Cloud BlogRead More