Class: CopyPaste

ol.interaction. CopyPaste


new CopyPaste(options)

An interaction to copy/paste features on a map

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
condition function

a function that take a mapBrowserEvent and return the actio nto perform: 'copy', 'cut' or 'paste', default Ctrl+C / Ctrl+V

features ol.Collection.<ol.Feature>

list of features to copy

sources ol.source.Vector | Array.<ol.source.Vector>

the source to copy from (used for cut), if not defined, it will use the destination

destination ol.source.Vector

the source to copy to

Fires:
  • event:focus
  • event:copy
  • event:paste

Extends

  • ol.interaction.Interaction

Methods


copy(options)

Set current feature to copy

Parameters:
Name Type Description
options Object
Properties
Name Type Description
features Array.<ol.Feature> | ol.Collection.<ol.Feature>

feature to copy, default get in the provided collection

cut boolean

try to cut feature from the sources, default false

silent boolean

true to send an event, default true


getDestination()

Get source to paste features

Parameters:
Type Description
ol.source.Vector

getFeatures()

Get current feature to copy

Returns:
Type
Array.<ol.Feature>

getSources()

Get sources to cut feature from

Returns:
Type
Array.<ol.source.Vector>

paste(options, features)

Paste features

Parameters:
Name Type Description
options Object
features Array.<ol.Feature> | ol.Collection.<ol.Feature>

feature to copy, default get current features

options.destination ol.source.Vector

Source to paste to, default the current source

options.silent boolean

true to send an event, default true


setDestination(source)

Source to paste features

Parameters:
Name Type Description
source ol.source.Vector

setSources(sources)

Sources to cut feature from

Parameters:
Name Type Description
sources ol.source.Vector | Array.<ol.source.Vector>