OpenLayers. Handler.Path

Handler to draw a path on the map.  Path is displayed on mouse down, moves on mouse move, and is finished on mouse up.

Inherits from

Summary
Handler to draw a path on the map.
Private.
{Boolean} In freehand mode, the handler starts the path on mouse down, adds a point for every mouse move, and finishes the path on mouse up.
{String} If set, freehandToggle is checked on mouse events and will set the freehand mode to the opposite of this.freehand.
Create a new path hander
Private.
Private.
Private.
Private.
Private.
Private.
Private.
Private.
Private.
Private.
Private.
{String} Name of class.

Properties

line

freehand

{Boolean} In freehand mode, the handler starts the path on mouse down, adds a point for every mouse move, and finishes the path on mouse up.  Outside of freehand mode, a point is added to the path on every mouse click and double-click finishes the path.

freehandToggle

{String} If set, freehandToggle is checked on mouse events and will set the freehand mode to the opposite of this.freehand.  To disallow toggling between freehand and non-freehand mode, set freehandToggle to null.  Acceptable toggle values are ‘shiftKey’, ‘ctrlKey’, and ‘altKey’.

Functions

OpenLayers. Handler.Path

Create a new path hander

Parameters

control{OpenLayers.Control}
callbacks{Array} An object with a ‘done’ property whos value is a function to be called when the path drawing is finished.  The callback should expect to recieve a single argument, the line string geometry.  If the callbacks object contains a ‘point’ property, this function will be sent each point as they are added.  If the callbacks object contains a ‘cancel’ property, this function will be called when the handler is deactivated while drawing.  The cancel should expect to receive a geometry.
options{Object} An optional object with properties to be set on the handler

createFeature

createFeature: function()

Private.  Add temporary geometries

destroyFeature

destroyFeature: function()

Private.  Destroy temporary geometries

addPoint

addPoint: function()

Private.  Add point to geometry.  Send the point index to override the behavior of LinearRing that disregards adding duplicate points.

freehandMode

freehandMode: function(evt)

Private.  Determine whether to behave in freehand mode or not.

Return: {Boolean}

modifyFeature

modifyFeature: function()

Private.  Modify the existing geometry given the new point

drawFeature

drawFeature: function()

Private.  Render geometries on the temporary layer.

geometryClone

geometryClone: function()

Private.  Return a clone of the relevant geometry.

Return: {OpenLayers.Geometry.LineString}

mousedown

mousedown: function(evt)

Private.  Handle mouse down.  Add a new point to the geometry and render it.  Return determines whether to propagate the event on the map.

Parameters

evt{Event} The browser event

Return

{Boolean} Allow event propagation

mousemove

mousemove: function (evt)

Private.  Handle mouse move.  Adjust the geometry and redraw.  Return determines whether to propagate the event on the map.

Parameters

evt{Event} The browser event

Return

{Boolean} Allow event propagation

mouseup

mouseup: function (evt)

Private.  Handle mouse up.  Send the latest point in the geometry to the control.  Return determines whether to propagate the event on the map.

Parameters

evt{Event} The browser event

Return

{Boolean} Allow event propagation

dblclick

dblclick: function(evt)

Private.  Handle double-clicks.  Finish the geometry and send it back to the control.

Parameters

evt{Event} The browser event

Return

{Boolean} Allow event propagation

Constants

CLASS_NAME

{String} Name of class.

createFeature: function()
Private.
destroyFeature: function()
Private.
addPoint: function()
Private.
freehandMode: function(evt)
Private.
modifyFeature: function()
Private.
drawFeature: function()
Private.
geometryClone: function()
Private.
mousedown: function(evt)
Private.
mousemove: function (evt)
Private.
mouseup: function (evt)
Private.
dblclick: function(evt)
Private.
Handler to draw a point on the map.
Vector features use the OpenLayers.Geometry classes as geometry description.
A LineString is a Curve which, once two points have been added to it, can never be less than two points long.