DrawingManager Class

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.

Name Return Type Description
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() DrawingMode Gets 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) number Returns the index of the shape in the drawing layer. Returns -1 if shape is not found.
remove(primitive: IPrimitive) IPrimitive Removes a shape from the layer and returns it.
removeAt(index: number) IPrimitive Removes 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.

Name Type Description
disposed Occurs when the drawing manager has been disposed.
drawingChanged IPrimitive Occurs after the shape has had a change. For example, finished dragging a vertex to a new location.
drawingChanging IPrimitive Occurs when the shape is being actively manipulated. For example, this event will continuously fire when dragging a vertex of a shape.
drawingEnded IPrimitive Occurs when the user has finished drawing or editing a shape.
drawingErased IPrimitive Occurs when a shape is erased.
drawingModeChanged DrawingMode Occurs when the drawing mode has changed.
drawingStarted IPrimitive Occurs when the user has started drawing or editing a shape.