Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HUAWEI HMS Core
Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.
Adds a polygon on a map layer.
Build Method | Description |
HWMapJsSDK.HWPolygon (polygonoptions) | The polygonoptions parameter is used to set the polygon attributes. For details, please refer to PolygonOptions. |
Method | Description | Parameter Type | Return Value |
getMap() | Obtains the map instance to which a polygon is bound. | None | |
setMap(map) | Binds a polygon to a map. | None | |
setPaths(paths) | Sets the path. | Array<Array<LatLng>> | None |
getPaths() | Obtains the path. | None | Array<Array<LatLng>> |
getFillColor() | Obtains the fill color of a polygon. | None | String |
setFillColor(fillColor) | Sets the fill color of a polygon. The following colors are supported:
| String | None |
getStrokeColor() | Obtains the stroke color of a polygon. | None | String |
setStrokeColor(strokeColor) | Sets the stroke color of a polygon. The following colors are supported:
| String | None |
| getStrokeLineDash() | Obtains the dotted line type of a polygon. | None | Array<Number> |
| setStrokeLineDash(strokeLineDash) | Sets the dotted line type of a polygon. | Array<Number> | None |
getStrokeWeight() | Obtains the stroke width of a polygon. | None | Number |
setStrokeWeight(strokeWeight) | Sets the stroke width of a polygon. | Number | None |
getVisible() | Obtains the visibility of a polygon. | None | Boolean |
setVisible(visible) | Sets the visibility of a polygon. | Boolean | None |
addListener(event, callback) | Adds an event listener. |
| None |
removeListener(event, callback) | Deletes an event listener. |
| None |
| getZIndex() | Obtains the Z-index of a polygon. | None | Number |
| setZIndex(zIndex) | Sets the Z-index of a polygon, that is, overlay relationship on the Z axis. | Number | None |
Event | Description | Usage |
click | Click on a polygon. | polygon.addListener('click', callback): The callback parameter indicates a customized callback function. |
dbclick | Double-click on a polygon. | polygon.addListener('dbclick', callback): The callback parameter indicates a customized callback function. |
mousedown | Mouse button press. | polygon.addListener('mousedown', callback): The callback parameter indicates a customized callback function. |
mouseup | Mouse button release. | polygon.addListener('mouseup', callback): The callback parameter indicates a customized callback function. |
Parameter | Mandatory (M)/Optional (O) | Type | Description |
map | M | Map instance. | |
paths | O | Array<Array<LatLng>> | Path array. The first path specifies a polygon, and each closed path following indicates a hole in the polygon. |
fillColor | O | String | Fill color of a polygon. The following colors are supported:
|
strokeColor | O | String | Stroke color of a polygon. The following colors are supported:
|
| strokeLineDash | O | Array<Number> | Dashed line type. The parameter value is an array of numbers defining the dash length and distance between dashes. If the number of elements in the array is an odd number, these elements will be copied and pasted in the array. For example, [5, 10, 15] will be changed to [5, 10, 15, 5, 10, 15]. |
strokeWeight | O | Number | Stroke width of a polygon, in pixels. |
visible | O | Boolean | Indicates whether the polygon is visible. The options include true (yes) and false (no). The default value is true. |
zIndex | O | Number | Z-index of a polygon, that is, overlay relationship on the Z axis (relative to the marker, circle, polygon, and polyline). |
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.