Provides an agent for splitting linear features on a vector layer given edits to linear features on any other vector layer or a temporary sketch layer. The control operates in two modes. By default, the control allows for temporary features to be drawn on a sketch layer (managed by the control) that will be used to split eligible features on the target layer. In auto-split mode, the control listens for edits (new features or modifications to existing features) on an editable layer and splits eligible features on a target layer.
The control can be added to a map as with other controls. It has no distinct visual representation but can be connected to a button or other tool to toggle activation with a click. In addition, no GUI elements are provided for control configuration. Collecting user input to configure behavior of the control is an application specific task.
See the Split API docs for a complete list of configuration options. The basic split feature example demonstrates use of the control in a complete example, and the snap split example demonstrates the Split control in conjunction with the Snapping control. While the other samples below are not complete working examples, they are intended to demonstrate different aspects of the control’s behavior.
Example usage:
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({layer: roads});
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({layer: roads, source: roads});
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({
layer: roads,
targetFilter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "surface",
value: "dirt"
})
});
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({
layer: roads,
source: roads,
tolerance: 0.01 // same units as roads geometries
});
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({
layer: roads,
eventListeners: {
"split": function(event) {
var road;
for(var i=0; i<event.features.length; ++i) {
road = event.features[i];
// attributes are cloned from original
road.attributes["length"] = road.getLength();
}
}
}
});
// Assume a vector layer named "roads".
var split = new OpenLayers.Control.Split({
layer: roads,
deferDelete: true,
tolerance: 0.001
});