OpenLayers.Control.Split - OpenLayers

# OpenLayers.Control.Split

Acts as a split feature agent while editing vector features.

#### Inherits from

- OpenLayers.Control

Summary

OpenLayers.Control.Split | Acts as a split feature agent while editing vector features.
Properties |
events | {OpenLayers.Events} Events instance for listeners and triggering control specific events.
layer | {OpenLayers.Layer.Vector} The target layer with features to be split.
source | {OpenLayers.Layer.Vector} Optional source layer.
sourceOptions | {Options} If a temporary sketch layer is created, these layer options will be applied.
tolerance | {Number} Distance between the calculated intersection and a vertex on the source geometry below which the existing vertex will be used for the split.
edge | {Boolean} Allow splits given intersection of edges only.
deferDelete | {Boolean} Instead of removing features from the layer, set feature states of split features to DELETE.
mutual | {Boolean} If source and target layers are the same, split source features and target features where they intersect.
targetFilter | {OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the target layer is eligible for splitting.
sourceFilter | {OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the source layer is eligible for splitting.
handler | {OpenLayers.Handler.Path} The temporary sketch handler created if no source layer is provided.
Constructor |
OpenLayers.Control.Split | Creates a new split control.
Functions |
setSource | Set the source layer for edits layer.
activate | Activate the control.
deactivate | Deactivate the control.
onSketchComplete | Registered as a listener for the sketchcomplete event on the editable layer.
afterFeatureModified | Registered as a listener for the afterfeaturemodified event on the editable layer.
removeByGeometry | Remove a feature from a list based on the given geometry.
isEligible | Test if a target feature is eligible for splitting.
considerSplit | Decide whether or not to split target features with the supplied feature.
geomsToFeatures | Create new features given a template feature and a list of geometries.
destroy | Clean up the control.

### Properties

### events

{OpenLayers.Events} Events instance for listeners and triggering control specific events.

#### Register a listener for a particular event with the following syntax

>     control.events.register(type, obj, listener);

#### Supported event types (in addition to those from OpenLayers.Control.events)

beforesplit | Triggered before a split occurs. Listeners receive an event object with source and target properties.
split | Triggered when a split occurs. Listeners receive an event with an original property and a features property. The original is a reference to the target feature that the sketch or modified feature intersects. The features property is a list of all features that result from this single split. This event is triggered before the resulting features are added to the layer (while the layer still has a reference to the original).
aftersplit | Triggered after all splits resulting from a single sketch or feature modification have occurred. The original features have been destroyed and features that result from the split have already been added to the layer. Listeners receive an event with a source and features property. The source references the sketch or modified feature used as a splitter. The features property is a list of all resulting features.

### layer

{OpenLayers.Layer.Vector} The target layer with features to be split. Set at construction or after construction with <setLayer>.

### source

{OpenLayers.Layer.Vector} Optional source layer. Any newly created or modified features from this layer will be used to split features on the target layer. If not provided, a temporary sketch layer will be created.

### sourceOptions

{Options} If a temporary sketch layer is created, these layer options will be applied.

### tolerance

{Number} Distance between the calculated intersection and a vertex on the source geometry below which the existing vertex will be used for the split. Default is null.

### edge

{Boolean} Allow splits given intersection of edges only. Default is true. If false, a vertex on the source must be within the tolerance distance of the calculated intersection for a split to occur.

### deferDelete

{Boolean} Instead of removing features from the layer, set feature states of split features to DELETE. This assumes a save strategy or other component is in charge of removing features from the layer. Default is false. If false, split features will be immediately deleted from the layer.

### mutual

{Boolean} If source and target layers are the same, split source features and target features where they intersect. Default is true. If false, only target features will be split.

### targetFilter

{OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the target layer is eligible for splitting.

### sourceFilter

{OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the source layer is eligible for splitting.

### handler

{OpenLayers.Handler.Path} The temporary sketch handler created if no source layer is provided.

### Constructor

### OpenLayers.Control.Split

Creates a new split control. A control is constructed with a target layer and an optional source layer. While the control is active, creating new features or modifying existing features on the source layer will result in splitting any eligible features on the target layer. If no source layer is provided, a temporary sketch layer will be created to create lines for splitting features on the target.

#### Parameters

options | {Object} An object containing all configuration properties for the control.

#### Valid options

layer | {OpenLayers.Layer.Vector} The target layer. Features from this layer will be split by new or modified features on the source layer or temporary sketch layer.
source | {OpenLayers.Layer.Vector} Optional source layer. If provided newly created features or modified features will be used to split features on the target layer. If not provided, a temporary sketch layer will be created for drawing lines.
tolerance | {Number} Optional value for the distance between a source vertex and the calculated intersection below which the split will occur at the vertex.
edge | {Boolean} Allow splits given intersection of edges only. Default is true. If false, a vertex on the source must be within the tolerance distance of the calculated intersection for a split to occur.
mutual | {Boolean} If source and target are the same, split source features and target features where they intersect. Default is true. If false, only target features will be split.
targetFilter | {OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the target layer is eligible for splitting.
sourceFilter | {OpenLayers.Filter} Optional filter that will be evaluated to determine if a feature from the target layer is eligible for splitting.

### Functions

### setSource

> setSource: function( | layer | )

Set the source layer for edits layer.

#### Parameters

layer | {OpenLayers.Layer.Vector} The new source layer layer. If null, a temporary sketch layer will be created.

### activate

> activate: function()

Activate the control. Activating the control registers listeners for editing related events so that during feature creation and modification, features in the target will be considered for splitting.

### deactivate

> deactivate: function()

Deactivate the control. Deactivating the control unregisters listeners so feature editing may proceed without engaging the split agent.

### onSketchComplete

> onSketchComplete: function( | event | )

Registered as a listener for the sketchcomplete event on the editable layer.

#### Parameters

event | {Object} The sketch complete event.

#### Returns

{Boolean} Stop the sketch from being added to the layer (it has been split).

### afterFeatureModified

> afterFeatureModified: function( | event | )

Registered as a listener for the afterfeaturemodified event on the editable layer.

#### Parameters

event | {Object} The after feature modified event.

### removeByGeometry

> removeByGeometry: function( | features,
> | geometry | )

Remove a feature from a list based on the given geometry.

#### Parameters

features | {Array(OpenLayers.Feature.Vector)} A list of features.
geometry | {OpenLayers.Geometry} A geometry.

### isEligible

> isEligible: function( | target | )

Test if a target feature is eligible for splitting.

#### Parameters

target | {OpenLayers.Feature.Vector} The target feature.

#### Returns

{Boolean} The target is eligible for splitting.

### considerSplit

> considerSplit: function( | feature | )

Decide whether or not to split target features with the supplied feature. If mutual is true, both the source and target features will be split if eligible.

#### Parameters

feature | {OpenLayers.Feature.Vector} The newly created or modified feature.

#### Returns

{Boolean} The supplied feature was split (and destroyed).

### geomsToFeatures

> geomsToFeatures: function( | feature,
> | geoms | )

Create new features given a template feature and a list of geometries. The list of geometries is modified in place. The result will be a list of new features.

#### Parameters

feature | {OpenLayers.Feature.Vector} The feature to be cloned.
geoms | {Array(OpenLayers.Geometry)} List of goemetries. This will become a list of new features.

### destroy

> destroy: function()

Clean up the control.

Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
This class represents an OGC Filter.
Handler to draw a path on the map.

> setSource: function( | layer | )

Set the source layer for edits layer.

> activate: function()

Activate the control.

> deactivate: function()

Deactivate the control.

> onSketchComplete: function( | event | )

Registered as a listener for the sketchcomplete event on the editable layer.

> afterFeatureModified: function( | event | )

Registered as a listener for the afterfeaturemodified event on the editable layer.

> removeByGeometry: function( | features,
> | geometry | )

Remove a feature from a list based on the given geometry.

> isEligible: function( | target | )

Test if a target feature is eligible for splitting.

> considerSplit: function( | feature | )

Decide whether or not to split target features with the supplied feature.

> geomsToFeatures: function( | feature,
> | geoms | )

Create new features given a template feature and a list of geometries.

> destroy: function()

Clean up the control.
Controls affect the display or behavior of the map.
{OpenLayers.Events} Events instance for listeners and triggering control specific events.
{Number} Distance between the calculated intersection and a vertex on the source geometry below which the existing vertex will be used for the split.
Vector features use the OpenLayers.Geometry classes as geometry description.
A Geometry is a description of a geographic object.
{Boolean} If source and target layers are the same, split source features and target features where they intersect.
Close