DrawingManager Class

Bing
 

The DrawingManager class manages the ability to draw and edit multiple shapes on the map. Shapes managed by this class are rendered on a separate drawing layer. User can use a mouse or a touch screen to draw on the map. When they are done, double clicking the map, pressing the escape button or any button on the toolbar will exit the current drawing mode. This class does not have a publicly accessible constructor and can only be accessed using the showDrawingManager of the DrawingTools class.

The DrawingManager class has the following methods.

NameReturn TypeDescription
add(data: IPrimitive or IPrimitive[], index?: number)Adds a shapes to the layer, at the specified index if specified.

  • data – The shape(s) to be added to the layer.
  • index – The index at which to insert the shape into the layer.
dispose()Disposes the drawing manager instance.
clear()Resets the drawing manager and clears all shapes in the drawing layer.
getDrawingMode()DrawingModeGets the current drawing mode of the drawing manager.
getPrimitives()IPrimitive[]Gets an array of shapes that are in the layer. This can be used to iterate over the individual shapes.
indexOf(primitive: IPrimitive, fromIndex?: number)numberReturns the index of the shape in the drawing layer. Returns -1 if shape is not found.
remove(primitive: IPrimitive)IPrimitiveRemoves a shape from the layer and returns it.
removeAt(index: number)IPrimitiveRemoves a shape from the layer at the specified index.
setDrawingMode(mode: DrawingMode)Sets the drawing mode of the drawing manager.
setOptions(options: DrawingManagerOptions)Sets the drawing tool options.
setPrimitives(primitives: IPrimitive[])Replaces all shapes in the layer with the new array of shapes that have been provided.

The DrawingManager class provides the following events.

NameTypeDescription
disposedOccurs when the drawing manager has been disposed.
drawingChangedIPrimitiveOccurs after the shape has had a change. For example, finished dragging a vertex to a new location.
drawingChangingIPrimitiveOccurs when the shape is being actively manipulated. For example, this event will continuously fire when dragging a vertex of a shape.
drawingEndedIPrimitiveOccurs when the user has finished drawing or editing a shape.
drawingErasedIPrimitiveOccurs when a shape is erased.
drawingModeChangedDrawingModeOccurs when the drawing mode has changed.
drawingStartedIPrimitiveOccurs when the user has started drawing or editing a shape.
Show: