目录

public final class Polyline

Defines a polyline, which is a list of vertices, where line segments are drawn between consecutive vertices. The following table describes attributes of a polyline.

Return typeMethod name
PointsVertices of a polyline. Line segments are drawn between consecutive points. A polyline is not closed by default. To form a closed polyline, the start and end vertices must be the same.
WidthLine segment width in screen pixels. The width is fixed and independent of the zoom level of the camera. The default value is 10.
ColorLine segment color in ARGB format, which is the same as the format used by Color. The default color is black (0xff000000).
VisibilityIndicates whether a polyline is visible, that is, whether it is drawn on the map. If the polygon is invisible, it will not be drawn but all other states will be preserved. The default value is true (yes).
ClickabilityIndicates whether to process the event triggered when a user taps a polyline. Set this attribute to true. You can change the value at any time. The default value is false.
TagRelated object of a polyline. For example, the object can contain data of the content represented by a polyline. This is easier than storing a separate Map<Polyline, Object>.

Public Fields

None.

Constructor

None.

Public Method Summary

Return typeMethod name
booleanequals(Object other)
intgetColor()
CapgetEndCap()
StringgetId()
intgetJointType()
List<PatternItem>getPattern()
List<LatLng>getPoints()
CapgetStartCap()
ObjectgetTag()
floatgetWidth()
floatgetZIndex()
inthashCode()
booleanisClickable()
booleanisGeodesic()
booleanisVisible()
voidremove()
voidsetClickable(boolean clickable)
voidsetColor(int color)
voidsetEndCap(Cap endCap)
voidsetGeodesic(boolean geodesic)
voidsetJointType(int jointType)
voidsetPattern(List<PatternItem> pattern)
voidsetPoints(List<LatLng> points)
voidsetStartCap(Cap startCap)
voidsetTag(Object tag)
voidsetVisible(boolean visible)
voidsetWidth(float width)
voidsetZIndex(float zIndex)

Public Methods

Method
public boolean equals(Object other)
Checks whether a polyline object equals another.


Parameters:

Parameter nameParameter desc
otherName of another polyline object.


Return:

Return typeParameter desc
booleanIf the polyline objects are equal, true is returned. Otherwise, false is returned.
Method
public int getColor()
Obtains the stroke color of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
intColor in ARGB format.
Method
public Cap getEndCap()
Obtains the end vertex of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
CapEnd vertex of a polyline.
Method
public String getId()
Obtains the ID of a polyline on a map. The ID will be unique among all polylines on a map.


Parameters:
None.
Return:

Return typeParameter desc
StringID of a polyline.
Method
public int getJointType()
Obtains the joint type of all vertices of a polyline, except the start and end vertices.


Parameters:
None.
Return:

Return typeParameter desc
intJoint type of a polyline. The default value is DEFAULT.
Method
public List<PatternItem> getPattern()
Obtains the stroke pattern of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
List<PatternItem>Stroke pattern of a polyline.
Method
public List<LatLng> getPoints()
Obtains the vertex set of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
List<LatLng>Vertex set of a polyline.
Method
public Cap getStartCap()
Obtains the start vertex of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
CapStart vertex of a polyline.
Method
public Object getTag()
Obtains the tag of a polyline if the tag has been set.


Parameters:
None.
Return:

Return typeParameter desc
ObjectTag of a polyline. If no tag has been set, null is returned.
Method
public float getWidth()
Obtains the stroke width of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
float

Stroke width of a polyline, in pixels.

Notice:
The stroke width returned by this API is one third of the actual width.
Method
public float getZIndex()
Obtains the z-index of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
floatZ-index, which indicates the overlapping order of a polyline.
Method
public int hashCode()
Obtains the hash code of a polyline.


Parameters:
None.
Return:

Return typeParameter desc
intHash code of a polyline.
Method
public boolean isClickable()
Checks whether a polyline is tappable.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf a polyline is tappable, true is returned. Otherwise, false is returned.
Method
public boolean isGeodesic()
Checks whether each segment of a polyline is drawn as a geodesic.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf each segment is drawn as a geodesic, true is returned. Otherwise, false is returned.
Method
public boolean isVisible()
Checks whether a polyline is visible.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf a polyline is visible, true is returned. Otherwise, false is returned.
Method
public void remove()
Removes a polyline from a map. After the polyline is removed, the operations of all its methods are undefined.


Parameters:
None.
Return:
None.

Method
public void setClickable(boolean clickable)
Specifies whether a polyline is tappable.


Parameters:

Parameter nameParameter desc
clickableIndicates whether a polyline is tappable. The default value is false.


Return:
None.

Method
public void setColor(int color)
Sets the stroke color of a polyline.


Parameters:

Parameter nameParameter desc
colorColor in ARGB format. By default, the stroke color is black (0xff000000).


Return:
None.

Method
public void setEndCap(Cap endCap)
Sets the end vertex of a polyline. By default, the end vertex is a ButtCap object.


Parameters:

Parameter nameParameter desc
endCapEnd vertex of a polyline.


Return:
None.

Method
public void setGeodesic(boolean geodesic)
Specifies whether to draw each segment of a polyline as a geodesic.


Parameters:

Parameter nameParameter desc
geodesicIndicates whether to draw each segment of a polyline as a geodesic. The options are true (yes) and false (no).


Return:
None.

Method
public void setJointType(int jointType)
Sets the joint type of all vertices of a polyline, except the start and end vertices. For details of the allowed joint types, please refer to JointType. If the joint type is not set or not an allowed one, the default value DEFAULT is used.


Parameters:

Parameter nameParameter desc
jointTypeJoint type. The default value is DEFAULT.


Return:
None.

Method
public void setPattern(List<PatternItem> pattern)
Sets the stroke pattern of a polyline. By default, the stroke pattern is solid, represented by null.


Parameters:

Parameter nameParameter desc
patternPatternItem object set.


Return:
None.

Method
public void setPoints(List<LatLng> points)
Sets vertex coordinates of a polyline.


Parameters:

Parameter nameParameter desc
pointsVertex set of a polyline.


Return:
None.

Method
public void setStartCap(Cap startCap)
Sets the start vertex of a polyline. By default, the start vertex is a ButtCap object.


Parameters:

Parameter nameParameter desc
startCapStart vertex of a polyline.


Return:
None.

Method
public void setTag(Object tag)
Sets the tag of a polyline. If null is passed, the existing tag is cleared.


Parameters:

Parameter nameParameter desc
tagTag of a polyline.


Return:
None.

Method
public void setVisible(boolean visible)
Specifies whether a polyline is visible. If the polyline is invisible, it will not be drawn but all other states will be preserved.


Parameters:

Parameter nameParameter desc
visibleIndicates whether a polyline is visible. The default value is true.


Return:
None.

Method
public void setWidth(float width)
Sets the stroke width of a polyline.


Parameters:

Parameter nameParameter desc
width

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

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


Return:
None.

Method
public void setZIndex(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 in a random order. By default, the z-index is 0.


Parameters:

Parameter nameParameter desc
zIndexZ-index, which indicates the overlapping order of a polyline.


Return:
None.