Class: CopyPaste

ol.interaction. CopyPaste

An interaction to copy/paste features on a map. It will fire a 'focus' event on the map when map is focused (use mapCondition option to handle the condition when the map is focused).


new CopyPaste(options)

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
condition function

a function that takes a mapBrowserEvent and return the action to perform: 'copy', 'cut' or 'paste', default Ctrl+C / Ctrl+V

mapCondition function

a function that takes a mapBrowserEvent and return true if the map is the active map, default always returns true

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

setMap(map)

Remove the interaction from its current map and attach it to the new map.

Parameters:
Name Type Description
map ol.Map

The map instance.


setSources(sources)

Sources to cut feature from

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