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 type | Method name |
| Points | Vertices 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. |
| Width | Line segment width in screen pixels. The width is fixed and independent of the zoom level of the camera. The default value is 10. |
| Color | Line segment color in ARGB format, which is the same as the format used by Color. The default color is black (0xff000000). |
| Visibility | Indicates 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). |
| Clickability | Indicates 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. |
| Tag | Related 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>. |
None.
None.
| Return type | Method name |
| boolean | equals(Object other) |
| int | getColor() |
| Cap | getEndCap() |
| String | getId() |
| int | getJointType() |
| List<PatternItem> | getPattern() |
| List<LatLng> | getPoints() |
| Cap | getStartCap() |
| Object | getTag() |
| float | getWidth() |
| float | getZIndex() |
| int | hashCode() |
| boolean | isClickable() |
| boolean | isGeodesic() |
| boolean | isVisible() |
| void | remove() |
| void | setClickable(boolean clickable) |
| void | setColor(int color) |
| void | setEndCap(Cap endCap) |
| void | setGeodesic(boolean geodesic) |
| void | setJointType(int jointType) |
| void | setPattern(List<PatternItem> pattern) |
| void | setPoints(List<LatLng> points) |
| void | setStartCap(Cap startCap) |
| void | setTag(Object tag) |
| void | setVisible(boolean visible) |
| void | setWidth(float width) |
| void | setZIndex(float zIndex) |
| Method |
| public boolean equals(Object other) |
| Checks whether a polyline object equals another. |
Parameters:
| Parameter name | Parameter desc |
| other | Name of another polyline object. |
Return:
| Return type | Parameter desc |
| boolean | If 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 type | Parameter desc |
| int | Color in ARGB format. |
| Method |
| public Cap getEndCap() |
| Obtains the end vertex of a polyline. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| Cap | End 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 type | Parameter desc |
| String | ID 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 type | Parameter desc |
| int | Joint 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 type | Parameter desc |
| List<PatternItem> | Stroke pattern of a polyline. |
| Method |
| public List<LatLng> getPoints() |
| Obtains the vertex set of a polyline. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| List<LatLng> | Vertex set of a polyline. |
| Method |
| public Cap getStartCap() |
| Obtains the start vertex of a polyline. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| Cap | Start vertex of a polyline. |
| Method |
| public Object getTag() |
| Obtains the tag of a polyline if the tag has been set. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| Object | Tag 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 type | Parameter 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 type | Parameter desc |
| float | Z-index, which indicates the overlapping order of a polyline. |
| Method |
| public int hashCode() |
| Obtains the hash code of a polyline. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| int | Hash code of a polyline. |
| Method |
| public boolean isClickable() |
| Checks whether a polyline is tappable. |
Parameters:
None.
Return:
| Return type | Parameter desc |
| boolean | If 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 type | Parameter desc |
| boolean | If 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 type | Parameter desc |
| boolean | If 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 name | Parameter desc |
| clickable | Indicates 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 name | Parameter desc |
| color | Color 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 name | Parameter desc |
| endCap | End 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 name | Parameter desc |
| geodesic | Indicates whether to draw each segment of a polyline as a geodesic. The options are true (yes) and false (no). |
Return:
None.
Parameters:
| Parameter name | Parameter desc |
| jointType | Joint 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 name | Parameter desc |
| pattern | PatternItem object set. |
Return:
None.
| Method |
| public void setPoints(List<LatLng> points) |
| Sets vertex coordinates of a polyline. |
Parameters:
| Parameter name | Parameter desc |
| points | Vertex 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 name | Parameter desc |
| startCap | Start 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 name | Parameter desc |
| tag | Tag 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 name | Parameter desc |
| visible | Indicates 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 name | Parameter 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.
Parameters:
| Parameter name | Parameter desc |
| zIndex | Z-index, which indicates the overlapping order of a polyline. |
Return:
None.