# 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

- OpenLayers.Handler.Point

Summary

OpenLayers.Handler.Path | Handler to draw a path on the map.
Properties |
line | {OpenLayers.Feature.Vector}
maxVertices | {Number} The maximum number of vertices which can be drawn by this handler.
doubleTouchTolerance | {Number} Maximum number of pixels between two touches for the gesture to be considered a “finalize feature” action.
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.
freehandToggle | {String} If set, freehandToggle is checked on mouse events and will set the freehand mode to the opposite of this.freehand.
timerId | {Integer} The timer used to test the double touch.
redoStack | {Array} Stack containing points removed with undo.
Constructor |
OpenLayers.Handler.Path | Create a new path hander
Functions |
createFeature | Add temporary geometries
destroyFeature | Destroy temporary geometries
destroyPersistedFeature | Destroy the persisted feature.
removePoint | Destroy the temporary point.
addPoint | Add point to geometry.
insertXY | Insert a point in the current sketch given x & y coordinates.
insertDeltaXY | Insert a point given offsets from the previously inserted point.
insertDirectionLength | Insert a point in the current sketch given a direction and a length.
insertDeflectionLength | Insert a point in the current sketch given a deflection and a length.
getCurrentPointIndex | {Number} The index of the most recently drawn point.
undo | Remove the most recently added point in the sketch geometry.
redo | Reinsert the most recently removed point resulting from an undo call.
freehandMode | Determine whether to behave in freehand mode or not.
modifyFeature | Modify the existing geometry given the new point
drawFeature | Render geometries on the temporary layer.
getSketch | Return the sketch feature.
getGeometry | Return the sketch geometry.
touchstart | handle touchstart.
down | Handle mousedown and touchstart.
move | Handle mousemove and touchmove.
up | Handle mouseup and touchend.
finishGeometry | Finish the geometry and send it back to the control.
dblclick | Handle double-clicks.

### Properties

### line

{OpenLayers.Feature.Vector}

### maxVertices

{Number} The maximum number of vertices which can be drawn by this handler. When the number of vertices reaches maxVertices, the geometry is automatically finalized. This property doesn’t apply if freehand is set. Default is null.

### doubleTouchTolerance

{Number} Maximum number of pixels between two touches for the gesture to be considered a “finalize feature” action. Default is 20.

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

### timerId

{Integer} The timer used to test the double touch.

### redoStack

{Array} Stack containing points removed with undo.

### Constructor

### OpenLayers.Handler.Path

Create a new path hander

#### Parameters

control | {OpenLayers.Control} The control that owns this handler
callbacks | {Object} An object with a properties whose values are functions. Various callbacks described below.
options | {Object} An optional object with properties to be set on the handler

#### Named callbacks

create | Called when a sketch is first created. Callback called with the creation point geometry and sketch feature.
modify | Called with each move of a vertex with the vertex (point) geometry and the sketch feature.
point | Called as each point is added. Receives the new point geometry.
done | Called when the point drawing is finished. The callback will recieve a single argument, the linestring geometry.
cancel | Called when the handler is deactivated while drawing. The cancel callback will receive a geometry.

### Functions

### createFeature

> createFeature: function( | pixel | )

Add temporary geometries

#### Parameters

pixel | {OpenLayers.Pixel} The initial pixel location for the new feature.

### destroyFeature

> destroyFeature: function( | force | )

Destroy temporary geometries

#### Parameters

force | {Boolean} Destroy even if persist is true.

### destroyPersistedFeature

> destroyPersistedFeature: function()

Destroy the persisted feature.

### removePoint

> removePoint: function()

Destroy the temporary point.

### addPoint

> addPoint: function( | pixel | )

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

#### Parameters

pixel | {OpenLayers.Pixel} The pixel location for the new point.

### insertXY

> insertXY: function( | x,
> | y | )

Insert a point in the current sketch given x & y coordinates. The new point is inserted immediately before the most recently drawn point.

#### Parameters

x | {Number} The x-coordinate of the point.
y | {Number} The y-coordinate of the point.

### insertDeltaXY

> insertDeltaXY: function( | dx,
> | dy | )

Insert a point given offsets from the previously inserted point.

#### Parameters

dx | {Number} The x-coordinate offset of the point.
dy | {Number} The y-coordinate offset of the point.

### insertDirectionLength

> insertDirectionLength: function( | direction,
> | length | )

Insert a point in the current sketch given a direction and a length.

#### Parameters

direction | {Number} Degrees clockwise from the positive x-axis.
length | {Number} Distance from the previously drawn point.

### insertDeflectionLength

> insertDeflectionLength: function( | deflection,
> | length | )

Insert a point in the current sketch given a deflection and a length. The deflection should be degrees clockwise from the previously digitized segment.

#### Parameters

deflection | {Number} Degrees clockwise from the previous segment.
length | {Number} Distance from the previously drawn point.

### getCurrentPointIndex

> getCurrentPointIndex: function()

#### Returns

{Number} The index of the most recently drawn point.

### undo

> undo: function()

Remove the most recently added point in the sketch geometry.

#### Returns

{Boolean} A point was removed.

### redo

> redo: function()

Reinsert the most recently removed point resulting from an undo call. The undo stack is deleted whenever a point is added by other means.

#### Returns

{Boolean} A point was added.

### freehandMode

> freehandMode: function( | evt | )

Determine whether to behave in freehand mode or not.

#### Returns

{Boolean}

### modifyFeature

> modifyFeature: function( | pixel,
> | drawing | )

Modify the existing geometry given the new point

#### Parameters

pixel | {OpenLayers.Pixel} The updated pixel location for the latest point.
drawing | {Boolean} Indicate if we’re currently drawing.

### drawFeature

> drawFeature: function()

Render geometries on the temporary layer.

### getSketch

> getSketch: function()

Return the sketch feature.

#### Returns

{OpenLayers.Feature.Vector}

### getGeometry

> getGeometry: function()

Return the sketch geometry. If <multi> is true, this will return a multi-part geometry.

#### Returns

{OpenLayers.Geometry.LineString}

### touchstart

> touchstart: function( | evt | )

handle touchstart.

#### parameters

evt | {event} the browser event

#### returns

{boolean} allow event propagation

### down

> down: function( | evt | )

Handle mousedown and touchstart. 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

### move

> move: function ( | evt | )

Handle mousemove and touchmove. 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

### up

> up: function ( | evt | )

Handle mouseup and touchend. 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

### finishGeometry

> finishGeometry: function()

Finish the geometry and send it back to the control.

### dblclick

> dblclick: function( | evt | )

Handle double-clicks.

#### Parameters

evt | {Event} The browser event

#### Returns

{Boolean} Allow event propagation

Vector features use the OpenLayers.Geometry classes as geometry description.

> undo: function()

Remove the most recently added point in the sketch geometry.

> createFeature: function( | pixel | )

Add temporary geometries

> destroyFeature: function( | force | )

Destroy temporary geometries

> destroyPersistedFeature: function()

Destroy the persisted feature.

> removePoint: function()

Destroy the temporary point.

> addPoint: function( | pixel | )

Add point to geometry.

> insertXY: function( | x,
> | y | )

Insert a point in the current sketch given x & y coordinates.

> insertDeltaXY: function( | dx,
> | dy | )

Insert a point given offsets from the previously inserted point.

> insertDirectionLength: function( | direction,
> | length | )

Insert a point in the current sketch given a direction and a length.

> insertDeflectionLength: function( | deflection,
> | length | )

Insert a point in the current sketch given a deflection and a length.

> getCurrentPointIndex: function()

{Number} The index of the most recently drawn point.

> redo: function()

Reinsert the most recently removed point resulting from an undo call.

> freehandMode: function( | evt | )

Determine whether to behave in freehand mode or not.

> modifyFeature: function( | pixel,
> | drawing | )

Modify the existing geometry given the new point

> drawFeature: function()

Render geometries on the temporary layer.

> getSketch: function()

Return the sketch feature.

> getGeometry: function()

Return the sketch geometry.

> touchstart: function( | evt | )

handle touchstart.

> down: function( | evt | )

Handle mousedown and touchstart.

> move: function ( | evt | )

Handle mousemove and touchmove.

> up: function ( | evt | )

Handle mouseup and touchend.

> finishGeometry: function()

Finish the geometry and send it back to the control.

> dblclick: function( | evt | )

Handle double-clicks.
Handler to draw a point on the map.
Controls affect the display or behavior of the map.
This class represents a screen coordinate, in x and y coordinates
A LineString is a Curve which, once two points have been added to it, can never be less than two points long.
Close