Class Info |
|---|
public final class Polyline Defines a polyline, which is a list of vertices, where line segments are drawn between consecutive vertices. An instance of this type will be returned when the addPolyline method in the HuaweiMap class is called. |
Qualifier and Type | Method Name and Description |
|---|---|
void | remove() Removes a polyline from a map. |
void | setClickable(boolean clickable) Sets whether a polyline is tappable. |
void | setColor(int color) Sets the stroke color of a polyline. |
void | setColorValues(List<Integer> colors) Sets colors for different segments of a polyline. |
void | Sets the end vertex cap of a polyline. |
void | setGeodesic(boolean geodesic) Sets whether to draw each segment of a polyline as a geodesic. |
void | setGradient(boolean on) Sets whether a polyline is gradient. |
void | setJointType(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. |
void | setPattern(List<PatternItem> pattern) Sets the stroke pattern of a polyline. |
void | setPoints(List<LatLng> points) Sets the vertex coordinates of a polyline. |
void | setStartCap(Cap startCap) Sets the start vertex cap of a polyline. |
void | setTag(Object tag) Sets the tag attribute of a polyline. |
void | setVisible(boolean visible) Sets whether a polyline is visible. |
void | setWidth(float width) Sets the stroke width of a polyline. |
void | setZIndex(float zIndex) Sets the z-index of a polyline. |
Method |
|---|
public void remove() Removes a polyline from a map. After the polyline is removed, the operations of all its methods will be undefined. |
Method |
|---|
public void setClickable(boolean clickable) Sets whether a polyline is tappable. |
Parameters
Name | Description |
|---|---|
clickable | Indicates whether a polyline is tappable.
The default value is false. |
Method |
|---|
public void setColor(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). |
Method |
|---|
public void setColorValues(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. |
Method |
|---|
public void setEndCap(Cap endCap) Sets the end vertex cap of a polyline. |
Parameters
Name | Description |
|---|---|
endCap | End vertex cap. The default value is ButtCap. |
Method |
|---|
public void setGeodesic(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.
|
Method |
|---|
public void setGradient(boolean on) Sets whether a polyline is gradient. |
Parameters
Name | Description |
|---|---|
on | Indicates whether a polyline is gradient.
|
Method |
|---|
public void setJointType(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. |
Method |
|---|
public void setPattern(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. |
Method |
|---|
public void setPoints(List<LatLng> points) Sets the vertex coordinates of a polyline. By default, a straight line is drawn between the end vertex of the polyline and the set vertex coordinate point. |
Parameters
Name | Description |
|---|---|
points | Vertex set of a polyline. By default, a polyline is not a closed area. To form a closed area, the start and end points of the polyline must be the same. |
Method |
|---|
public void setStartCap(Cap startCap) Sets the start vertex cap of a polyline. |
Parameters
Name | Description |
|---|---|
startCap | Start vertex cap. The default value is ButtCap. |
Method |
|---|
public void setTag(Object tag) Sets the tag attribute of a polyline. The tag attribute can be any object. If null is passed, the tag attribute will be cleared. If you no longer use the tag attribute, call setTag(null) to clear it to prevent memory leakage from occurring on the app. |
Parameters
Name | Description |
|---|---|
tag | Tag of a polyline. |
Method |
|---|
public void setVisible(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. The default value is true. |
Method |
|---|
public void setWidth(float width) Sets the stroke width of a polyline. |
Parameters
Name | Description |
|---|---|
width | Stroke width of a polyline, in pixels. The value must be greater than or equal to 0. The default value is 10. NOTE: To ensure compatibility, it is recommended that the actual stroke width triples the passed parameter value. |
Throws
Name | Description |
|---|---|
IllegalArgumentException | If the passed stroke width is a negative number. |
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 by the order in which they are added. NOTE: The following formula must be met: Number of circles and polygons x 2 + Number of polylines and ground overlays ≤ 1450. If the formula is not met, overlapping errors may occur. |
Parameters
Name | Description |
|---|---|
zIndex | Z-index, which indicates the overlapping order of a polyline. By default, the z-index is 0. |