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).

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:

Subclasses

Extends

Observable Properties

Name Type Settable ol/Object.ObjectEvent type Description
active boolean yes change:active

true if the interaction is active, false otherwise.

Methods

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

interaction/DragBox.js, line 181

Returns geometry of last drawn box.

Returns:
Geometry.

handleEvent() inherited

interaction/Pointer.js, line 120

Handles the map browser event and may call into other functions, if event sequences like e.g. 'drag' or 'down-up' etc. are detected.