ALKMaps.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 ALKMaps.Control.ModifyFeature constructor.

Inherits From

Summary
ALKMaps.Control.ModifyFeatureControl to modify features.
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.
clickout{Boolean} Unselect features when clicking outside any feature.
toggle{Boolean} Unselect a selected feature on click.
standalone{Boolean} Set to true to create a control without SelectFeature capabilities.
layer{ALKMaps.Layer.Vector}
feature{ALKMaps.Feature.Vector} Feature currently available for modification.
vertices{Array(ALKMaps.Feature.Vector)} Verticies currently available for dragging.
virtualVertices{Array(ALKMaps.Feature.Vector)} Virtual vertices in the middle of each edge.
selectControl{ALKMaps.Control.SelectFeature}
dragControl{ALKMaps.Control.DragFeature}
handlers{Object}
deleteCodes{Array(Integer)} Keycodes for deleting verticies.
virtualStyle{Object} A symbolizer to be used for virtual vertices.
vertexRenderIntent{String} The renderIntent to use for vertices.
mode{Integer} Bitfields specifying the modification mode.
createVertices{Boolean} Create new vertices by dragging the virtual vertices in the middle of each edge.
modified{Boolean} The currently selected feature has been modified.
radiusHandle{ALKMaps.Feature.Vector} A handle for rotating/resizing a feature.
dragHandle{ALKMaps.Feature.Vector} A handle for dragging a feature.
onModificationStart{Function} Deprecated.
onModification{Function} Deprecated.
onModificationEnd{Function} Deprecated.
Constructor
ALKMaps.Control.ModifyFeatureCreate a new modify feature control.
Functions
destroyTake care of things that are not handled in superclass.
activateActivate the control.
deactivateDeactivate the control.
beforeSelectFeatureCalled before a feature is selected.
selectFeatureSelect a feature for modification in standalone mode.
unselectFeatureCalled when the select feature control unselects a feature.
dragStartCalled by the drag feature control with before a feature is dragged.
dragVertexCalled by the drag feature control with each drag move of a vertex.
dragCompleteCalled by the drag feature control when the feature dragging is complete.
setFeatureStateCalled when the feature is modified.
resetVertices
handleKeypressCalled by the feature handler on keypress.
collectVerticesCollect the vertices from the modifiable feature’s geometry and push them on to the control’s vertices array.
collectDragHandleCollect the drag handle for the selected geometry.
collectRadiusHandleCollect the radius handle for the selected geometry.
setMapSet the map property for the control and all handlers.
Constants
RESHAPE{Integer} Constant used to make the control work in reshape mode
RESIZE{Integer} Constant used to make the control work in resize mode
ROTATE{Integer} Constant used to make the control work in rotate mode
DRAG{Integer} Constant used to make the control work in drag mode

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.

clickout

{Boolean} Unselect features when clicking outside any feature.  Default is true.

toggle

{Boolean} Unselect a selected feature on click.  Default is true.

standalone

{Boolean} Set to true to create a control without SelectFeature capabilities.  Default is false.  If standalone is true, to modify a feature, call the selectFeature method with the target feature.  Note that you must call the unselectFeature method to finish feature modification in standalone mode (before starting to modify another feature).

feature

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

vertices

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

virtualVertices

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

handlers

{Object}

deleteCodes

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

virtualStyle

{Object} A symbolizer to be used for virtual vertices.

vertexRenderIntent

{String} The renderIntent to use for vertices.  If no virtualStyle is provided, this renderIntent will also be used for virtual vertices, with a fillOpacity and strokeOpacity of 0.3.  Default is null, which means that the layer’s default style will be used for vertices.

mode

{Integer} Bitfields specifying the modification mode.  Defaults to ALKMaps.Control.ModifyFeature.RESHAPE.  To set the mode to a combination of options, use the | operator.  For example, to allow the control to both resize and rotate features, use the following syntax

control.mode = ALKMaps.Control.ModifyFeature.RESIZE |
               ALKMaps.Control.ModifyFeature.ROTATE;

createVertices

{Boolean} Create new vertices by dragging the virtual vertices in the middle of each edge.  Default is true.

modified

{Boolean} The currently selected feature has been modified.

radiusHandle

{ALKMaps.Feature.Vector} A handle for rotating/resizing a feature.

dragHandle

{ALKMaps.Feature.Vector} A handle for dragging a feature.

onModificationStart

{Function} Deprecated.  Register for “beforefeaturemodified” instead.  The “beforefeaturemodified” event is triggered on the layer before any modification begins.

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} Deprecated.  Register for “featuremodified” instead.  The “featuremodified” event is triggered on the layer with each feature modification.

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

onModificationEnd

{Function} Deprecated.  Register for “afterfeaturemodified” instead.  The “afterfeaturemodified” event is triggered on the layer after a feature has been modified.

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

Constructor

ALKMaps.Control.ModifyFeature

Create a new modify feature control.

Parameters

layer{ALKMaps.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.

Returns

{Boolean} Successfully activated the control.

deactivate

deactivate: function()

Deactivate the control.

Returns

{Boolean} Successfully deactivated the control.

beforeSelectFeature

beforeSelectFeature: function(feature)

Called before a feature is selected.

Parameters

feature{ALKMaps.Feature.Vector} The feature about to be selected.

selectFeature

selectFeature: function(feature)

Select a feature for modification in standalone mode.  In non-standalone mode, this method is called when the select feature control selects a feature.  Register a listener to the beforefeaturemodified event and return false to prevent feature modification.

Parameters

feature{ALKMaps.Feature.Vector} the selected feature.

unselectFeature

unselectFeature: function(feature)

Called when the select feature control unselects a feature.

Parameters

feature{ALKMaps.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{ALKMaps.Feature.Vector} The point or vertex about to be dragged.
pixel{ALKMaps.Pixel} Pixel location of the mouse event.

dragVertex

dragVertex: function(vertex,
pixel)

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

Parameters

vertex{ALKMaps.Feature.Vector} The vertex being dragged.
pixel{ALKMaps.Pixel} Pixel location of the mouse event.

dragComplete

dragComplete: function(vertex)

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

Parameters

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

setFeatureState

setFeatureState: function()

Called when the feature is modified.  If the current state is not INSERT or DELETE, the state is set to UPDATE.

resetVertices

resetVertices: function()

handleKeypress

handleKeypress: function(evt)

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

Parameters

evt{Event} Keypress event.

collectVertices

collectVertices: function()

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

collectDragHandle

collectDragHandle: function()

Collect the drag handle for the selected geometry.

collectRadiusHandle

collectRadiusHandle: function()

Collect the radius handle for the selected geometry.

setMap

setMap: function(map)

Set the map property for the control and all handlers.

Parameters

map{ALKMaps.Map} The control’s map.

Constants

RESHAPE

{Integer} Constant used to make the control work in reshape mode

RESIZE

{Integer} Constant used to make the control work in resize mode

ROTATE

{Integer} Constant used to make the control work in rotate mode

DRAG

{Integer} Constant used to make the control work in drag mode

Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources.
Vector features use the ALKMaps.Geometry classes as geometry description.
The SelectFeature control selects vector features from a given layer on click or hover.
The DragFeature control moves a feature with a drag of the mouse.
destroy: function()
Take care of things that are not handled in superclass.
activate: function()
Activate the control.
deactivate: function()
Deactivate the control.
beforeSelectFeature: function(feature)
Called before a feature is selected.
selectFeature: function(feature)
Select a feature for modification in standalone mode.
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,
pixel)
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.
setFeatureState: function()
Called when the feature is modified.
resetVertices: function()
handleKeypress: function(evt)
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.
collectDragHandle: function()
Collect the drag handle for the selected geometry.
collectRadiusHandle: function()
Collect the radius handle for the selected geometry.
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.
{Object} A symbolizer to be used for virtual vertices.
{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 ALKMaps.Map are interactive maps embedded in a web page.
Close