Class Info |
|---|
public final class Polygon Defines a polygon on the surface of the Earth. A polygon can be convex or concave. It can span the 180 meridian and have holes that are not filled in. An instance of this type will be returned when the addPolygon method in the HuaweiMap class is called. |
Qualifier and Type | Method Name and Description |
|---|---|
List<PatternItem> | Obtains the stroke pattern of a polygon's outline. |
Object | getTag() Obtains the tag attribute of a polygon. |
void | remove() Removes a polygon from a map. |
void | setClickable(boolean clickable) Sets whether a polygon is tappable. |
void | setFillColor(int color) Sets the fill color of a polygon. |
void | setGeodesic(boolean geodesic) Sets whether to draw each segment of a polygon as a geodesic. |
void | setHoles(List<? extends List<LatLng>> holes) Sets holes in a polygon. |
void | setPoints(List<LatLng> points) Sets vertex coordinates of a polygon. |
void | setStrokeColor(int color) Sets the stroke color of a polygon's outline. |
void | setStrokeJointType(int jointType) Sets the joint type of a polygon. |
void | setStrokePattern(List<PatternItem> pattern) Sets the stroke pattern of a polygon's outline. |
void | setStrokeWidth(float width) Sets the stroke width of a polygon's outline. |
void | setTag(Object tag) Sets the tag attribute of a polygon. |
void | setVisible(boolean visible) Sets whether a polygon is visible. |
void | setZIndex(float zIndex) Sets the z-index of a polygon. |
Method |
|---|
public int getFillColor() Obtains the fill color of a polygon, in ARGB format. |
Returns
Type | Description |
|---|---|
int | Color in ARGB format. |
Method |
|---|
public List<PatternItem> getStrokePattern() Obtains the stroke pattern of a polygon's outline. |
Returns
Type | Description |
|---|---|
List<PatternItem> | Stroke pattern of a polygon's outline. |
Method |
|---|
public Object getTag() Obtains the tag attribute (if it has been set) of a polygon. |
Returns
Type | Description |
|---|---|
Object | Object if a tag has been set; null otherwise. |
Method |
|---|
public void setClickable(boolean clickable) Sets whether a polygon is tappable. |
Parameters
Name | Description |
|---|---|
clickable | Indicates whether a polygon is tappable.
The default value is false. |
Method |
|---|
public void setFillColor(int color) Sets the fill color of a polygon. |
Parameters
Name | Description |
|---|---|
color | Color in ARGB format. By default, the fill color is transparent (0x00000000). |
Method |
|---|
public void setGeodesic(boolean geodesic) Sets whether to draw each segment of a polygon as a geodesic. |
Parameters
Name | Description |
|---|---|
geodesic | Indicates whether to draw each segment of a polygon as a geodesic.
The default value is false. |
Method |
|---|
public void setHoles(List<? extends List<LatLng>> holes) Sets holes in a polygon. |
Parameters
Name | Description |
|---|---|
holes | Hole list. Each hole is a LatLng list. |
Method |
|---|
public void setPoints(List<LatLng> points) Sets vertex coordinates of a polygon. |
Parameters
Name | Description |
|---|---|
points | Vertex coordinate set. |
Method |
|---|
public void setStrokeColor(int color) Sets the stroke color of a polygon's outline. |
Parameters
Name | Description |
|---|---|
color | Color in ARGB format. By default, the stroke color is black (0xff000000). |
Method |
|---|
public void setStrokeJointType(int jointType) Sets the joint type of a polygon. |
Parameters
Name | Description |
|---|---|
jointType | Joint type. The default value is DEFAULT. |
Method |
|---|
public void setStrokePattern(List<PatternItem> pattern) Sets the stroke pattern of a polygon's outline. |
Parameters
Name | Description |
|---|---|
pattern | PatternItem object set. The default value is null, indicating that the stroke is in the solid pattern. |
Method |
|---|
public void setStrokeWidth(float width) Sets the stroke width of a polygon's outline. |
Parameters
Name | Description |
|---|---|
width | Stroke width of a polygon's outline, in pixels. The default value is 10. |
Method |
|---|
public void setTag(Object tag) Sets the tag attribute of a polygon. 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 polygon. |
Method |
|---|
public void setVisible(boolean visible) Sets whether a polygon is visible. If the polygon is invisible, it will not be drawn but all other states will be preserved. |
Parameters
Name | Description |
|---|---|
visible | Indicates whether a polygon is visible. By default, a polygon is visible. |
Method |
|---|
public void setZIndex(float zIndex) Sets the z-index of a polygon. The z-index indicates the overlapping order of a polygon. A polygon with a larger z-index overlaps that with a smaller z-index. Polygons 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 polygon. By default, the z-index is 0. |