OpenLayers. Control. ModifyFeature

Control to modify features.  When activated, a click renders the vertices of a feature - these vertices can then be dragged.  By default, the delete key will delete the vertex under the mouse.  New features are added by dragging “virtual vertices” between vertices.  Create a new control with the OpenLayers.Control.ModifyFeature constructor.

Inherits From

Summary
Control to modify features.
{Array(String)} To restrict modification to a limited set of geometry types, send a list of strings corresponding to the geometry class names.
{OpenLayers.Feature.Vector} Feature currently available for modification.
{Array(OpenLayers.Feature.Vector)} Verticies currently available for dragging.
{Array(OpenLayers.Feature.Vector)} Virtual vertices in the middle of each edge.
{<OpenLayers.Control.Select>}
{<OpenLayers.Handler.Keyboard>}
{Array(Integer)} Keycodes for deleting verticies.
{<OpenLayers.Feature.Vector.Style>}
{Function} Optional function to be called when a feature is selected to be modified.
{Function} Optional function to be called when a feature has been modified.
{Function} Optional function to be called when a feature is finished being modified.
Create a new modify feature control.
Take care of things that are not handled in superclass.
Activate the control and the feature handler.
Deactivate the controls.
Called when the select feature control selects a feature.
Called when the select feature control unselects a feature.
Called by the drag feature control with before a feature is dragged.
Called by the drag feature control with each drag move of a vertex.
Called by the drag feature control when the feature dragging is complete.
Called by the feature handler on keypress.
Collect the vertices from the modifiable feature’s geometry and push them on to the control’s vertices array.
Set the map property for the control and all handlers.

Properties

geometryTypes

{Array(String)} To restrict modification to a limited set of geometry types, send a list of strings corresponding to the geometry class names.

feature

{OpenLayers.Feature.Vector} Feature currently available for modification.

vertices

{Array(OpenLayers.Feature.Vector)} Verticies currently available for dragging.

virtualVertices

{Array(OpenLayers.Feature.Vector)} Virtual vertices in the middle of each edge.

selectControl

{<OpenLayers.Control.Select>}

keyboardHandler

{<OpenLayers.Handler.Keyboard>}

deleteCodes

{Array(Integer)} Keycodes for deleting verticies.  Set to null to disable vertex deltion by keypress.  If non-null, keypresses with codes in this array will delete vertices under the mouse.  Default is 46 and 100, the ‘delete’ and lowercase ‘d’ keys.

virtualStyle

{<OpenLayers.Feature.Vector.Style>}

onModificationStart

{Function} Optional function to be called when a feature is selected to be modified.  The function should expect to be called with a feature.  This could be used for example to allow to lock the feature on server-side.

onModification

{Function} Optional function to be called when a feature has been modified.  The function should expect to be called with a feature.

onModificationEnd

{Function} Optional function to be called when a feature is finished being modified.  The function should expect to be called with a feature.

Constructor

OpenLayers. Control. ModifyFeature

Create a new modify feature control.

Parameters

layer{OpenLayers.Layer.Vector} Layer that contains features that will be modified.
options{Object} Optional object whose properties will be set on the control.

Functions

destroy

destroy: function()

Take care of things that are not handled in superclass.

activate

activate: function()

Activate the control and the feature handler.

Returns

{Boolean} Successfully activated the control and feature handler.

deactivate

deactivate: function()

Deactivate the controls.

Returns

{Boolean} Successfully deactivated the control.

selectFeature

selectFeature: function(feature)

Called when the select feature control selects a feature.

Parameters

feature{OpenLayers.Feature.Vector} The selected feature.

unselectFeature

unselectFeature: function(feature)

Called when the select feature control unselects a feature.

Parameters

feature{OpenLayers.Feature.Vector} The unselected feature.

dragStart

dragStart: function(feature,
pixel)

Called by the drag feature control with before a feature is dragged.  This method is used to differentiate between points and vertices of higher order geometries.  This respects the geometryTypes property and forces a select of points when the drag control is already active (and stops events from propagating to the select control).

Parameters

feature{OpenLayers.Feature.Vector} The point or vertex about to be dragged.
pixel{OpenLayers.Pixel} Pixel location of the mouse event.

dragVertex

dragVertex: function(vertex)

Called by the drag feature control with each drag move of a vertex.

Parameters

vertex{OpenLayers.Feature.Vector} The vertex being dragged.

dragComplete

dragComplete: function(vertex)

Called by the drag feature control when the feature dragging is complete.

Parameters

vertex{OpenLayers.Feature.Vector} The vertex being dragged.

resetVertices

resetVertices: function()

handleKeypress

handleKeypress: function(code)

Called by the feature handler on keypress.  This is used to delete vertices and point features.  If the <deleteCode> property is set, vertices and points will be deleted when a feature is selected for modification and the mouse is over a vertex.

Parameters

{Integer} Key code corresponding to the keypress event.

collectVertices

collectVertices: function()

Collect the vertices from the modifiable feature’s geometry and push them on to the control’s vertices array.

setMap

setMap: function(map)

Set the map property for the control and all handlers.

Parameters

map{OpenLayers.Map} The control’s map.
Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
Vector features use the OpenLayers.Geometry classes as geometry description.
Move a feature with a drag.
destroy: function()
Take care of things that are not handled in superclass.
activate: function()
Activate the control and the feature handler.
deactivate: function()
Deactivate the controls.
selectFeature: function(feature)
Called when the select feature control selects a feature.
unselectFeature: function(feature)
Called when the select feature control unselects a feature.
dragStart: function(feature,
pixel)
Called by the drag feature control with before a feature is dragged.
dragVertex: function(vertex)
Called by the drag feature control with each drag move of a vertex.
dragComplete: function(vertex)
Called by the drag feature control when the feature dragging is complete.
resetVertices: function()
handleKeypress: function(code)
Called by the feature handler on keypress.
collectVertices: function()
Collect the vertices from the modifiable feature’s geometry and push them on to the control’s vertices array.
setMap: function(map)
Set the map property for the control and all handlers.
Create a new modify feature control.
Controls affect the display or behavior of the map.
{Array(String)} To restrict modification to a limited set of geometry types, send a list of strings corresponding to the geometry class names.
This class represents a screen coordinate, in x and y coordinates
Instances of OpenLayers.Map are interactive maps embedded in a web page.