Class: Draw

ol.interaction.Draw

Interaction that allows drawing geometries.

new ol.interaction.Draw(options)

Name Type Description
options

Options.

Name Type Description
features ol.Collection.<ol.Feature> | undefined experimental

Destination collection for the drawn features.

source ol.source.Vector | undefined experimental

Destination source for the drawn features.

snapTolerance number | undefined experimental

Pixel distance for snapping to the drawing finish. Default is 12.

type ol.geom.GeometryType experimental

Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', or 'MultiPolygon').

minPointsPerRing number | undefined experimental

The number of points that must be drawn before a polygon ring can be finished. Default is 3.

style ol.style.Style | Array.<ol.style.Style> | ol.style.StyleFunction | undefined experimental

Style for sketch features.

geometryName string | undefined experimental

Geometry name to use for features created by the draw interaction.

condition ol.events.ConditionType | undefined experimental

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled. By default ol.events.condition.noModifierKeys adds a vertex.

Fires:

Extends

Methods

dispatchChangeEvent() inherited experimental

Dispatches a change event.

Fires:
  • change experimental

getRevision(){number} inherited experimental

Returns:
Revision.

on(type, listener, opt_this){goog.events.Key} inherited

Listen for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object to use as this in listener.

Returns:
Unique key for the listener.

once(type, listener, opt_this){goog.events.Key} inherited

Listen once for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object to use as this in listener.

Returns:
Unique key for the listener.

un(type, listener, opt_this) inherited

Unlisten for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object which was used as this by the listener.

Removes an event listener using the key returned by on() or once().

Name Type Description
key goog.events.Key

Key.