OpenLayers.Control.ModifyFeature.BySegment

A mixin for the ModifyFeature control to allow editing of large geometries by editing one segment at a time, the segment which is closest to the mouse cursor on hover.

To use this is in combination with OpenLayers.Control.ModifyFeature include this file in your build and set bySegment to true on the ModifyFeature control.  Also note this code depends on the rbush library which can be found at: https://github.com/mourner/rbush

Summary
OpenLayers.Control.ModifyFeature.BySegmentA mixin for the ModifyFeature control to allow editing of large geometries by editing one segment at a time, the segment which is closest to the mouse cursor on hover.
Properties
hoverTolerance{Integer} Number of pixels around the hover location to query the spatial index in order to find the closest segment.
Functions
collectVerticesCollect the vertices from the modifiable feature’s geometry and push them on to the control’s vertices array.
setMapSet the map property for the control and all handlers.
deactivateHoverDeactivate the hover handler.
destroyTake care of things that are not handled in superclass.
dragStartCalled by the drag handler before a feature is dragged.
dragCompleteCalled by the drag handler when the feature dragging is complete.
onHoverMoveMove listener of the hover handler.
createSpatialIndexCreates a spatial index for all the segments of the feature’s geometry.
createBBOXCreate an array of 4 points (minx, miny, maxx, maxy) that represents the bounding box of the 2 provided points.
updateSpatialIndexUpdate the spatial index after a (virtual) vertex gets moved.

Properties

hoverTolerance

{Integer} Number of pixels around the hover location to query the spatial index in order to find the closest segment.  Defaults to 25.

Functions

collectVertices

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.

deactivateHover

deactivateHover: function()

Deactivate the hover handler.

destroy

destroy: function()

Take care of things that are not handled in superclass.

dragStart

dragStart: function(feature)

Called by the drag handler before a feature is dragged.  This method is used to differentiate between points and vertices of higher order geometries.

Parameters

feature{OpenLayers.Feature.Vector} The point or vertex about to be dragged.

dragComplete

dragComplete: function(vertex)

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

Parameters

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

onHoverMove

onHoverMove: function(evt)

Move listener of the hover handler.  Draws the 2 vertices of the segment closest to the mouse cursor, and one virtual vertex in the center of the segment.

Parameters

evt{Object} The event object.

createSpatialIndex

createSpatialIndex: function(evt)

Creates a spatial index for all the segments of the feature’s geometry.

Parameters

evt{Object} The event object.

createBBOX

createBBOX: function(point1,
point2)

Create an array of 4 points (minx, miny, maxx, maxy) that represents the bounding box of the 2 provided points.

Parameters

point1{OpenLayers.Geometry.Point} The first point.
point2{OpenLayers.Geometry.Point} The second point.

Returns: {Array(float)}

updateSpatialIndex

updateSpatialIndex: function(vertex)

Update the spatial index after a (virtual) vertex gets moved.

Parameters

vertex{OpenLayers.Feature.Vector}
setMap: function(map)
Set the map property for the control and all handlers.
deactivateHover: function()
Deactivate the hover handler.
destroy: function()
Take care of things that are not handled in superclass.
dragStart: function(feature)
Called by the drag handler before a feature is dragged.
dragComplete: function(vertex)
Called by the drag handler when the feature dragging is complete.
onHoverMove: function(evt)
Move listener of the hover handler.
createSpatialIndex: function(evt)
Creates a spatial index for all the segments of the feature’s geometry.
createBBOX: function(point1,
point2)
Create an array of 4 points (minx, miny, maxx, maxy) that represents the bounding box of the 2 provided points.
updateSpatialIndex: function(vertex)
Update the spatial index after a (virtual) vertex gets moved.
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Vector features use the OpenLayers.Geometry classes as geometry description.
Point geometry class.
Close