Class: DragAndDrop

ol/interaction/DragAndDrop~DragAndDrop


import DragAndDrop from 'ol/interaction/DragAndDrop';

Handles input of vector data by drag and drop.

new DragAndDrop(opt_options)

interaction/DragAndDrop.js, line 90
Name Type Description
options

Options.

Name Type Description
formatConstructors Array.<Class.<module:ol/format/Feature~FeatureFormat>>

Format constructors.

source module:ol/source/Vector~VectorSource

Optional vector source where features will be added. If a source is provided all existing features will be removed and new features will be added when they are dropped on the target. If you want to add features to a vector source without removing the existing features (append only), instead of providing the source option listen for the "addfeatures" event.

projection module:ol/proj~ProjectionLike

Target projection. By default, the map's view's projection is used.

target HTMLElement

The element that is used as the drop target, default is the viewport element.

Fires:

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

getActive(){boolean} inherited

interaction/Interaction.js, line 60

Return whether the interaction is currently active.

Returns:
true if the interaction is active, false otherwise.

getMap(){module:ol/PluggableMap~PluggableMap} inherited

interaction/Interaction.js, line 69

Get the map associated with this interaction.

Returns:
Map.

handleEvent(mapBrowserEvent){boolean} inherited

interaction/Interaction.js, line 79

Handles the map browser event.

Name Type Description
mapBrowserEvent module:ol/MapBrowserEvent~MapBrowserEvent

Map browser event.

Returns:
false to stop event propagation.

setActive(active) inherited

interaction/Interaction.js, line 89

Activate or deactivate the interaction.

Name Type Description
active boolean

Active.