Class: DragBox

ol/interaction/DragBox~DragBox


import DragBox from 'ol/interaction/DragBox';

Allows the user to draw a vector box by clicking and dragging on the map, normally combined with an module:ol/events/condition that limits it to when the shift or other key is held down. This is used, for example, for zooming to a specific area of the map (see module:ol/interaction/DragZoom~DragZoom and module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom).

This interaction is only supported for mouse devices.

new DragBox(opt_options)

interaction/DragBox.js, line 112
Name Type Description
options

Options.

Name Type Default Description
className string 'ol-dragbox'

CSS class name for styling the box.

condition module:ol/events/condition~Condition

A function that takes an module:ol/MapBrowserEvent~MapBrowserEvent and returns a boolean to indicate whether that event should be handled. Default is ol/events/condition~always.

minArea number 64

The minimum area of the box in pixel, this value is used by the default boxEndCondition function.

boxEndCondition module:ol/interaction/DragBox~EndCondition

A function that takes a module:ol/MapBrowserEvent~MapBrowserEvent and two module:ol/pixel~Pixels to indicate whether a boxend event should be fired. Default is true if the area of the box is bigger than the minArea option.

onBoxEnd function

Code to execute just before boxend is fired.

Fires:

Methods

getGeometry(){module:ol/geom/Polygon~Polygon}

interaction/DragBox.js, line 170

Returns geometry of last drawn box.

Returns:
Geometry.