Classes
Methods
-
module:ol/interaction/Draw.createBox(){module:ol/interaction/Draw~GeometryFunction}
interaction/Draw.js, line 1064 -
import {createBox} from 'ol/interaction/Draw';Create a
geometryFunctionthat will create a box-shaped polygon (aligned with the coordinate system axes). Use this with the draw interaction andtype: 'Circle'to return a box instead of a circle geometry.Returns:
Function that draws a box-shaped polygon.
-
module:ol/interaction/Draw.createRegularPolygon(opt_sides, opt_angle){module:ol/interaction/Draw~GeometryFunction}
interaction/Draw.js, line 1033 -
import {createRegularPolygon} from 'ol/interaction/Draw';Create a
geometryFunctionfortype: 'Circle'that will create a regular polygon with a user specified number of sides and start angle instead of anmodule:ol/geom/Circle~Circlegeometry.Name Type Description sidesnumber Number of sides of the regular polygon. Default is 32.
anglenumber Angle of the first point in radians. 0 means East. Default is the angle defined by the heading from the center of the regular polygon to the current pointer position.
Returns:
Function that draws a polygon.
Type Definitions
-
GeometryFunction()
interaction/Draw.js, line 107 -
Function that takes an array of coordinates and an optional existing geometry and a projection as arguments, and returns a geometry. The optional existing geometry is the geometry that is returned when the function is called without a second argument.
-
LineCoordType{Array.<module:ol/coordinate~Coordinate>}
-
Coordinate type when drawing lines.
-
Options{Object}
-
Properties:
Name Type Argument Default Description typemodule:ol/geom/GeometryType Geometry type of the geometries being drawn with this instance.
clickTolerancenumber <optional>
6 The maximum distance in pixels between "down" and "up" for a "up" event to be considered a "click" event and actually add a point/vertex to the geometry being drawn. The default of
6was chosen for the draw interaction to behave correctly on mouse as well as on touch devices.featuresmodule:ol/Collection~Collection.<module:ol/Feature~Feature> <optional>
Destination collection for the drawn features.
sourcemodule:ol/source/Vector~VectorSource <optional>
Destination source for the drawn features.
dragVertexDelaynumber <optional>
500 Delay in milliseconds after pointerdown before the current vertex can be dragged to its exact position.
snapTolerancenumber <optional>
12 Pixel distance for snapping to the drawing finish.
stopClickboolean <optional>
false Stop click, singleclick, and doubleclick events from firing during drawing.
maxPointsnumber <optional>
The number of points that can be drawn before a polygon ring or line string is finished. By default there is no restriction.
minPointsnumber <optional>
The number of points that must be drawn before a polygon ring or line string can be finished. Default is
3for polygon rings and2for line strings.finishConditionmodule:ol/events/condition~Condition <optional>
A function that takes an
module:ol/MapBrowserEvent~MapBrowserEventand returns a boolean to indicate whether the drawing can be finished.stylemodule:ol/style/Style~StyleLike <optional>
Style for sketch features.
geometryFunctionmodule:ol/interaction/Draw~GeometryFunction <optional>
Function that is called when a geometry's coordinates are updated.
geometryNamestring <optional>
Geometry name to use for features created by the draw interaction.
conditionmodule:ol/events/condition~Condition <optional>
A function that takes an
module:ol/MapBrowserEvent~MapBrowserEventand returns a boolean to indicate whether that event should be handled. By defaultmodule:ol/events/condition~noModifierKeys, i.e. a click, adds a vertex or deactivates freehand drawing.freehandboolean <optional>
false Operate in freehand mode for lines, polygons, and circles. This makes the interaction always operate in freehand mode and takes precedence over any
freehandConditionoption.freehandConditionmodule:ol/events/condition~Condition <optional>
Condition that activates freehand drawing for lines and polygons. This function takes an
module:ol/MapBrowserEvent~MapBrowserEventand returns a boolean to indicate whether that event should be handled. The default ismodule:ol/events/condition~shiftKeyOnly, meaning that the Shift key activates freehand drawing.wrapXboolean <optional>
false Wrap the world horizontally on the sketch overlay.
-
PointCoordType{module:ol/coordinate~Coordinate}
-
Coordinate type when drawing points.
-
PolyCoordType{Array.<Array.<module:ol/coordinate~Coordinate>>}
-
Coordinate type when drawing polygons.
-
Types used for drawing coordinates.
OpenLayers