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.

Only Essential Cookies
Accept All

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core ReferencesMap KitJavaScript APIHWPolygon

HWPolygon

Overview

Adds a polygon on a map layer.

Build Method

Expand

Build Method

Description

HWMapJsSDK.HWPolygon (polygonoptions)

The polygonoptions  parameter is used to set the polygon attributes. For details, please refer to  PolygonOptions.

Public Methods

Expand

Method

Description

Parameter Type

Return Value

getMap()

Obtains the map instance to which a  polygon is bound.

None

HWMap

setMap(map)

Binds a polygon to a map.

HWMap

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:

  • Color name: green

  • Hexadecimal value: #ff0000

  • RGB: rgb(0,0,0)

  • RGBA: rgba(0,0,0,0.5)

  • HSL: hsl(120,65%,75%)

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:

  • Color name: green

  • Hexadecimal value: #ff0000

  • RGB: rgb(0,0,0)

  • RGBA: rgba(0,0,0,0.5)

  • HSL: hsl(120,65%,75%)

String

None

getStrokeLineDash()Obtains the dotted line type of a polygon.NoneArray<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.

  • event: event, which is of the String type. For details, please refer to Events.

  • callback: callback function triggered by an event.


None

removeListener(event, callback)

Deletes an event listener.

  • event: event, which is of the String type. For details, please refer to Events.

  • callback: callback function triggered by an event.

None

getZIndex()Obtains the Z-index of a polygon.NoneNumber
setZIndex(zIndex)Sets the Z-index of a polygon, that is, overlay relationship on the Z axis.NumberNone

Events

Expand

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.

PolygonOptions

Expand

Parameter

Mandatory (M)/Optional (O)

Type

Description

map

M

HWMap

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:

  • Color name: green

  • Hexadecimal value: #ff0000

  • RGB: rgb(0,0,0)

  • RGBA: rgba(0,0,0,0.5)

  • HSL: hsl(120,65%,75%)

strokeColor

O

String

Stroke color of a  polygon.

The following colors are supported:

  • Color name: green

  • Hexadecimal value: #ff0000

  • RGB: rgb(0,0,0)

  • RGBA: rgba(0,0,0,0.5)

  • HSL: hsl(120,65%,75%)

strokeLineDashOArray<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).


This page may contain third-party content. For details, click here.
Search in References
Enter a keyword.