目录

DrawingManager

Overview

Provides tools for drawing shapes like polygons, rectangles, circles, and polylines.

Constructor

Constructor

Description

drawing.DrawingManager(options)

Creates a DrawingManager instance. In the constructor, options is used to set DrawingManager attributes. For details, please refer to DrawingManagerOptions.

Methods

Method

Description

Type

Return Value

getDrawingMode()

Obtains the drawing mode of DrawingManager.

-

OverlayType

getMap()

Obtains the bound map instance.

-

HWMap

setDrawingMode(drawingMode)

Sets the drawing mode of DrawingManager.

OverlayType

-

setMap(map,HWMapJsSDK)

Sets the map to which the drawn shape will be bound.

HWMap

-

setOptions(options)

Sets options for DrawingManager.

DrawingManagerOptions

-

DrawingManagerOptions

Parameter

Mandatory

Type

Description

boxOptions

No

BoxOptions

Sets the custom style for a rectangle.

circleOptions

No

CircleOptions

Sets the custom style for a circle.

drawingControl

Yes

Boolean

Indicates whether to enable the drawing control.

  • true: yes
  • false: no

The default value is true.

drawingControlOptions

No

DrawingControlOptions

Drawing control display options.

drawingMode

No

OverlayType

Drawing mode, which specifies the type of the ground overlay to be drawn. The default value is None.

polygonOptions

No

PolygonOptions

Sets the custom style for a polygon.

polylineOptions

No

PolylineOptions

Sets the custom style for a polyline.

map

No

HWMap

Map instance.

markerOptions

No

MarkerOptions

Sets the custom style for a point.

onComplete

No

Function

Called when the drawing is completed.

NOTE:

The callback function has two parameters:

  • result: shape object of the current operation. If type is set to 2, you can call result.getInstance() to obtain an HW Object instance and call result.getObjectType() to obtain the type of the current HW Object instance (Marker, Circle, Polygon, or Polyline).
  • type: type of the tool used for drawing a shape. The options are 1 (OLOBJECT) and 2 (HWOBJECT).

onChange

No

Function

Called when the shape is changed.

NOTE:

The callback function has two parameters:

  • result: shape object of the current operation. If type is set to 2, you can call result.getInstance() to obtain an HW Object instance and call result.getObjectType() to obtain the type of the current HW Object instance (Marker, Circle, Polygon, or Polyline).
  • type: type of the tool used for drawing a shape. The options are 1 (OLOBJECT) and 2 (HWOBJECT).

selectedObjectType

No

SelectedObjectType

Object type used for drawing. The options include HW Object (default) and OL Object.

showSelectedObjectType

No

Boolean

Indicates whether to show the HW Object and OL Object select boxes.

  • true: yes
  • false: no

The default value is false.

BoxOptions

Parameter

Mandatory

Type

Description

fillColor

No

String

Fill color. The default value is #D8D8D8.

The color can be set in hexadecimal, for example, #ff0000.

fillOpacity

No

Number

Opacity of the fill color. The value range is [0, 1].

0: transparent

1: opaque

The default value is 0.6.

strokeColor

No

String

Stroke color. The default value is #969696.

The color can be set in hexadecimal, for example, #ff0000.

strokeWeight

No

Number

Stroke width, in pixels. The default value is 4.

clickable

No

Boolean

Indicates whether the shape can be clicked.

true: yes

false: no

The default value is true.

editable

No

Boolean

Indicates whether the shape can be edited.

true: yes

false: no

The default value is false.

CircleOptions

Parameter

Mandatory

Type

Description

fillColor

No

String

Fill color. The default value is #D8D8D8.

The color can be set in hexadecimal, for example, #ff0000.

fillOpacity

No

Number

Opacity of the fill color. The value range is [0, 1].

0: transparent

1: opaque

The default value is 1.

strokeColor

No

String

Stroke color. The default value is #969696.

The color can be set in hexadecimal, for example, #ff0000.

strokeWeight

No

Number

Stroke width, in pixels. The default value is 4.

clickable

No

Boolean

Indicates whether the shape can be clicked.

true: yes

false: no

The default value is true.

editable

No

Boolean

Indicates whether the shape can be edited.

true: yes

false: no

The default value is false.

PolygonOptions

Parameter

Mandatory

Type

Description

fillColor

No

String

Fill color. The default value is #D8D8D8.

The color can be set in hexadecimal, for example, #ff0000.

fillOpacity

No

Number

Opacity of the fill color. The value range is [0, 1].

0: transparent

1: opaque

The default value is 0.6.

strokeColor

No

String

Stroke color. The default value is #969696.

The color can be set in hexadecimal, for example, #ff0000.

strokeWeight

No

Number

Stroke width, in pixels. The default value is 4.

clickable

No

Boolean

Indicates whether the shape can be clicked.

true: yes

false: no

The default value is true.

editable

No

Boolean

Indicates whether the shape can be edited.

true: yes

false: no

The default value is false.

maxPoints

No

Number

Maximum number of vertices in a polygon.

PolylineOptions

Parameter

Mandatory

Type

Description

fillColor

No

String

Fill color. The default value is #D8D8D8.

The color can be set in hexadecimal, for example, #ff0000.

fillOpacity

No

Number

Opacity of the fill color. The value range is [0, 1].

0: transparent

1: opaque

The default value is 1.

strokeColor

No

String

Stroke color. The default value is #969696.

The color can be set in hexadecimal, for example, #ff0000.

strokeWeight

No

Number

Stroke width, in pixels. The default value is 4.

clickable

No

Boolean

Indicates whether the shape can be clicked.

true: yes

false: no

The default value is true.

editable

No

Boolean

Indicates whether the shape can be edited.

true: yes

false: no

The default value is false.

MarkerOptions

Parameter

Mandatory

Type

Description

icon

No

Icon

Icon of a marker, which can be the URL of an image or a file path.

Icon

Parameter

Mandatory

Type

Description

url

No

String

Image address, which can be the image URL or file path. By default, a built-in image is provided.

DrawingControlOptions

Parameter

Mandatory

Type

Description

drawingModes

No

Array<OverlayType>

Order for displaying elements in the drawing control. The hand icon (which corresponds to the null drawing mode) is always available and does not need to be specified in this array. By default, elements are sorted in the following order: point, circle, polygon, polyline, and rectangle.

position

No

ControlPosition

Position ID, which specifies the position for displaying the control on the map. The default value is TOP_CENTER.

OverlayType

Constant

Description

NONE

Do not set any drawing mode.

POINT

Specifies DrawingManager to create a point.

CIRCLE

Specifies DrawingManager to create a circle.

POLYGON

Specifies DrawingManager to create a polygon.

LINE_STRING

Specifies DrawingManager to create a polyline.

BOX

Specifies DrawingManager to create a rectangle.

ControlPosition

Constant

Description

BOTTOM_CENTER

The drawing control is displayed in the center of the bottom side.

BOTTOM_LEFT

The drawing control is displayed in the lower left corner.

BOTTOM_RIGHT

The drawing control is displayed in the lower right corner.

LEFT_CENTER

The drawing control is displayed in the center of the left side.

RIGHT_CENTER

The drawing control is displayed in the center of the right side.

TOP_CENTER

The drawing control is displayed in the center of the top side.

TOP_LEFT

The drawing control is displayed in the upper left corner, and flows towards the middle.

TOP_RIGHT

The drawing control is displayed in the upper right corner, and flows towards the middle.

SelectedObjectType

Constant

Description

HWOBJECT

Specifies to use HW Object for drawing.

OLOBJECT

Specifies to use OL Object for drawing.