Handler to draw a path on the map. Path is displayed on mouse down, moves on mouse move, and is finished on mouse up.
ALKMaps. | Handler to draw a path on the map. |
Properties | |
line | {ALKMaps.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 | |
ALKMaps. | 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. |
{Array} Stack containing points removed with undo.
Create a new path hander
control | {ALKMaps.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 |
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 receive a single argument, the linestring geometry. |
cancel | Called when the handler is deactivated while drawing. The cancel callback will receive a geometry. |
createFeature: function( pixel )
Add temporary geometries
pixel | {ALKMaps.Pixel} The initial pixel location for the new feature. |
addPoint: function( pixel )
Add point to geometry. Send the point index to override the behavior of LinearRing that disregards adding duplicate points.
pixel | {ALKMaps.Pixel} The pixel location for the new point. |
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.
deflection | {Number} Degrees clockwise from the previous segment. |
length | {Number} Distance from the previously drawn point. |
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.
{Boolean} A point was added.
modifyFeature: function( pixel, drawing )
Modify the existing geometry given the new point
pixel | {ALKMaps.Pixel} The updated pixel location for the latest point. |
drawing | {Boolean} Indicate if we’re currently drawing. |
Remove the most recently added point in the sketch geometry.
undo: function()
Add temporary geometries
createFeature: function( pixel )
Destroy temporary geometries
destroyFeature: function( force )
Destroy the persisted feature.
destroyPersistedFeature: function()
Destroy the temporary point.
removePoint: function()
Add point to geometry.
addPoint: function( pixel )
Insert a point in the current sketch given x & y coordinates.
insertXY: function( x, y )
Insert a point given offsets from the previously inserted point.
insertDeltaXY: function( dx, dy )
Insert a point in the current sketch given a direction and a length.
insertDirectionLength: function( direction, length )
Insert a point in the current sketch given a deflection and a length.
insertDeflectionLength: function( deflection, length )
{Number} The index of the most recently drawn point.
getCurrentPointIndex: function()
Reinsert the most recently removed point resulting from an undo call.
redo: function()
Determine whether to behave in freehand mode or not.
freehandMode: function( evt )
Modify the existing geometry given the new point
modifyFeature: function( pixel, drawing )
Render geometries on the temporary layer.
drawFeature: function()
Return the sketch feature.
getSketch: function()
Return the sketch geometry.
getGeometry: function()
handle touchstart.
touchstart: function( evt )
Handle mousedown and touchstart.
down: function( evt )
Handle mousemove and touchmove.
move: function ( evt )
Handle mouseup and touchend.
up: function ( evt )
Finish the geometry and send it back to the control.
finishGeometry: function()
Handle double-clicks.
dblclick: function( evt )