Class: DrawHandler

DrawHandler

new DrawHandler(viewer, mode, clampMode)

Draw processor object classes. Support the drawing of rasterized surface objects.

Name Type Default Description
viewer Viewer

Viewer object.

mode DrawMode

Drawing mode, including points, lines, faces, and icons.

clampMode ClampMode ClampMode.Space optional

绘制风格,包含空间、贴地、贴对象(S3M模型)。

Example
var handler = new SuperMap3D.DrawHandler(viewer,SuperMap3D.DrawMode.Line,ClampMode.Ground);
handler.activate();

Members

readonly activeEvtEvent

Draw the activation event for the handler

Example
handler.activeEvt.addEventListener(function(result){

});

clampModeClampMode

Get or set the style of drawing geometric objects, including spatial, ground, and object pasting

Default Value:
ClampMode.Space

readonly drawEvtEvent

Draw completion event, listen to the completed drawing event, and obtain the current drawing result.

When the drawing mode is DrawMode. Point, the result of the event callback is {object: point}.

When the drawing mode is DrawMode. Polygon, the result of the event callback is {object: polygon}.

When the drawing mode is DrawMode. Line, the result of the event callback is {object: polyline}.

When the drawing mode is DrawMode. Marker, the result of the event callback is {object: marker}.

Example
handler.drawEvt.addEventListener(function(result){
    console.log(result);
});

enableDepthTestBoolean

Set whether to enable depth detection for drawn graphics elements

Default Value:
true

lineColorColor

Get or set the line color for drawing geometric objects.

Default Value:
Color.fromCssColorString('#51ff00')

lineMaterialMaterial

Get or set the line material for drawing geometric objects.

Default Value:
ColorMaterialProperty

lineWidthNumber

Get or set the line width for drawing geometric objects.

Default Value:
3.0

snappingEnabledBoolean

Get or set whether to enable capture

Default Value:
true

Methods

activate()

Activate handler

clear()

Clear all graphic elements

deactivate()

Make the handler invalid

destroy()

清除绘制结果,关闭绘制处理器,销毁持有的捕捉对象资源 一旦对象被销毁,就不应再调用,调用任何函数都将导致DeveloperError异常。 因此,按照示例中的方法将返回值(undefined)赋值给对象

Example
handler = handler && handler.destroy();

getLinePositions(){Array.<Cartesian3>}

Obtain the position of the drawn line

Returns:
Type Description
Array.<Cartesian3> Cartesian coordinate point array.