目录

PolylineOptions

Class Info

public class PolylineOptions

Implements the Parcelable API and defines attributes for a polyline.

Public Constructor Summary

Constructor Name

PolylineOptions()

Default constructor of the PolylineOptions class.

Public Method Summary

Qualifier and Type

Method Name and Description

PolylineOptions

add(LatLng... points)

Adds multiple vertices to a polyline.

PolylineOptions

add(LatLng point)

Adds a vertex to a polyline.

PolylineOptions

addAll(Iterable<LatLng> points)

Adds a group of vertices to a polyline.

PolylineOptions

clickable(boolean clickable)

Sets whether a polyline is tappable.

PolylineOptions

color(int color)

Sets the stroke color of a polyline.

PolylineOptions

colorValues(List<Integer> colors)

Sets colors for different segments of a polyline.

PolylineOptions

endCap(Cap endCap)

Sets the end vertex cap of a polyline.

PolylineOptions

geodesic(boolean geodesic)

Sets whether to draw each segment of a polyline as a geodesic.

Cap

getEndCap()

Obtains the end vertex cap of a polyline.

List<PatternItem>

getPattern()

Obtains the stroke pattern of a polyline.

Cap

getStartCap()

Obtains the start vertex cap of a polyline.

PolylineOptions

jointType(int jointType)

Sets the joint type of all vertices of a polyline, except the start and end vertices. For details about the allowed joint types, please refer to JointType.

PolylineOptions

pattern(List<PatternItem> pattern)

Sets the stroke pattern of a polyline.

PolylineOptions

startCap(Cap startCap)

Sets the start vertex cap of a polyline.

PolylineOptions

visible(boolean visible)

Sets whether a polyline is visible.

PolylineOptions

width(float width)

Sets the stroke width of a polyline.

PolylineOptions

zIndex(float zIndex)

Sets the z-index of a polyline.

PolylineOptions

gradient(boolean on)

Sets whether a polyline is gradient.

Public Methods

[h2]add(LatLng... points)

Method

public PolylineOptions add(LatLng... points)

Adds multiple vertices to a polyline.

Parameters

Name

Description

points

Coordinates of multiple vertices.

Returns

Type

Description

PolylineOptions

PolylineOptions object containing the specified vertices.

[h2]add(LatLng point)

Method

public PolylineOptions add(LatLng point)

Adds a vertex to a polyline.

Parameters

Name

Description

point

Coordinates of a vertex.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new vertex setting.

[h2]addAll

Method

public PolylineOptions addAll(Iterable<LatLng> points)

Adds a group of vertices to a polyline.

Parameters

Name

Description

points

Multiple vertices.

Returns

Type

Description

PolylineOptions

PolylineOptions object containing the specified vertices.

[h2]clickable

Method

public PolylineOptions clickable(boolean clickable)

Sets whether a polyline is tappable.

Parameters

Name

Description

clickable

Indicates whether a polyline is tappable.

  • true: yes
  • false: no

The default value is false.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new tappability setting.

[h2]color

Method

public PolylineOptions color(int color)

Sets the stroke color of a polyline.

Parameters

Name

Description

color

Color in ARGB format. By default, the stroke color is black (0xff000000).

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new polyline stroke color.

[h2]colorValues

Method

public PolylineOptions colorValues(List<Integer> colors)

Sets colors for different segments of a polyline.

Parameters

Name

Description

colors

Colors of different segments of a polyline, in ARGB format.

Returns

Type

Description

PolylineOptions

PolylineOptions object containing the set colors.

[h2]endCap

Method

public PolylineOptions endCap(Cap endCap)

Sets the end vertex cap of a polyline.

Parameters

Name

Description

endCap

End vertex cap of a polyline. The default value is ButtCap.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new end vertex cap setting.

[h2]geodesic

Method

public PolylineOptions geodesic(boolean geodesic)

Sets whether to draw each segment of a polyline as a geodesic. If this parameter is not set, the default value false will be returned.

Parameters

Name

Description

geodesic

Indicates whether to draw each segment of a polyline as a geodesic.

  • true: yes
  • false: no

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new geodesic attribute setting.

[h2]getEndCap

Method

public Cap getEndCap()

Obtains the end vertex cap of a polyline.

Returns

Type

Description

Cap

End vertex cap of a polyline. If no vertex cap is set, the default value ButtCap will be returned.

[h2]getPattern

Method

public List<PatternItem> getPattern()

Obtains the stroke pattern of a polyline.

Returns

Type

Description

List<PatternItem>

Stroke pattern of a polyline.

[h2]getStartCap

Method

public Cap getStartCap()

Obtains the start vertex cap of a polyline.

Returns

Type

Description

Cap

Start vertex cap of a polyline. If no vertex cap is set, the default value ButtCap will be returned.

[h2]jointType

Method

public PolylineOptions jointType(int jointType)

Sets the joint type of all vertices of a polyline, except the start and end vertices. For details about the allowed joint types, please refer to JointType. If the joint type is not set or not an allowed one, the default value DEFAULT will be used.

Parameters

Name

Description

jointType

Joint type. The default value is DEFAULT.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new joint type.

[h2]pattern

Method

public PolylineOptions pattern(List<PatternItem> pattern)

Sets the stroke pattern of a polyline.

Parameters

Name

Description

pattern

PatternItem object set. The default value is null, indicating that the stroke is in the solid pattern.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new pattern setting.

[h2]startCap

Method

public PolylineOptions startCap(Cap startCap)

Sets the start vertex cap of a polyline.

Parameters

Name

Description

startCap

Start vertex cap. The default value is ButtCap.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new start vertex cap setting.

[h2]visible

Method

public PolylineOptions visible(boolean visible)

Sets whether a polyline is visible. If the polyline is invisible, it will not be drawn but all other states will be preserved.

Parameters

Name

Description

visible

Indicates whether a polyline is visible.

  • true: yes
  • false: no

The default value is true.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new visibility setting.

[h2]width

Method

public PolylineOptions width(float width)

Sets the stroke width of a polyline.

Parameters

Name

Description

width

Stroke width of a polyline, in pixels. The default value is 10.

NOTE:

To ensure compatibility, the actual stroke width triples the passed parameter value.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new polyline stroke width.

Throws

Name

Description

IllegalArgumentException

If the passed stroke width is a negative number.

[h2]zIndex

Method

public PolylineOptions zIndex(float zIndex)

Sets the z-index of a polyline. The z-index indicates the overlapping order of a polyline. A polyline with a larger z-index overlaps that with a smaller z-index. Polylines with the same z-index overlap each other by the order in which they are added.

Parameters

Name

Description

zIndex

Z-index, which indicates the overlapping order of a polyline. By default, the z-index is 0.

Returns

Type

Description

PolylineOptions

PolylineOptions object with the new z-index.

[h2]gradient

Method

public PolylineOptions gradient(boolean on)

Sets whether a polyline is gradient.

Parameters

Name

Description

on

Indicates whether a polyline is gradient.

  • true: yes
  • false (default): no

Returns

Type

Description

PolylineOptions

PolylineOptions object containing the gradient setting.