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.
{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
Add temporary geometries
Destroy temporary geometries
Add point to geometry.
Determine whether to behave in freehand mode or not.
Modify the existing geometry given the new point
Render geometries on the temporary layer.
Return a clone of the relevant geometry.
Handle mouse down.
Handle mouse move.
Handle mouse up.
Handle double-clicks.

Properties

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’.

Constructor

OpenLayers. Handler.Path

Create a new path hander

Parameters

control{OpenLayers.Control}
callbacks{Object} 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

Functions

createFeature

createFeature: function()

Add temporary geometries

destroyFeature

destroyFeature: function()

Destroy temporary geometries

addPoint

addPoint: function()

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

freehandMode

freehandMode: function(evt)

Determine whether to behave in freehand mode or not.

Returns

{Boolean}

modifyFeature

modifyFeature: function()

Modify the existing geometry given the new point

drawFeature

drawFeature: function()

Render geometries on the temporary layer.

geometryClone

geometryClone: function()

Return a clone of the relevant geometry.

Returns

{OpenLayers.Geometry.LineString}

mousedown

mousedown: function(evt)

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

Returns

{Boolean} Allow event propagation

mousemove

mousemove: function (evt)

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

Parameters

evt{Event} The browser event

Returns

{Boolean} Allow event propagation

mouseup

mouseup: function (evt)

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

Returns

{Boolean} Allow event propagation

dblclick

dblclick: function(evt)

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

Parameters

evt{Event} The browser event

Returns

{Boolean} Allow event propagation

Vector features use the OpenLayers.Geometry classes as geometry description.
createFeature: function()
Add temporary geometries
destroyFeature: function()
Destroy temporary geometries
addPoint: function()
Add point to geometry.
freehandMode: function(evt)
Determine whether to behave in freehand mode or not.
modifyFeature: function()
Modify the existing geometry given the new point
drawFeature: function()
Render geometries on the temporary layer.
geometryClone: function()
Return a clone of the relevant geometry.
mousedown: function(evt)
Handle mouse down.
mousemove: function (evt)
Handle mouse move.
mouseup: function (evt)
Handle mouse up.
dblclick: function(evt)
Handle double-clicks.
Handler to draw a point on the map.
Controls affect the display or behavior of the map.
A LineString is a Curve which, once two points have been added to it, can never be less than two points long.