ALKMaps.Handler.Polygon

Handler to draw a polygon on the map.  Polygon is displayed on mouse down, moves on mouse move, and is finished on mouse up.  Modified to use ALKPath handler.

Inherits from

Summary
ALKMaps.Handler.PolygonHandler to draw a polygon on the map.
Properties
holeModifier{String} Key modifier to trigger hole digitizing.
drawingHole{Boolean} Currently drawing an interior ring.
polygon{ALKMaps.Feature.Vector}
Constructor
ALKMaps.Handler.PolygonCreate a Polygon Handler.
Functions
createFeatureAdd temporary geometries
addPointAdd point to geometry.
getCurrentPointIndex{Number} The index of the most recently drawn point.
enforceTopologySimple topology enforcement for drawing interior rings.
finishGeometryFinish the geometry and send it back to the control.
finalizeInteriorRingEnforces that new ring has some area and doesn’t contain vertices of any other rings.
cancelFinish the geometry and call the “cancel” callback.
restoreFeatureMove the feature from the sketch layer to the target layer.
destroyFeatureDestroy temporary geometries
drawFeatureRender geometries on the temporary layer.
getSketchReturn the sketch feature.
getGeometryReturn the sketch geometry.

Properties

holeModifier

{String} Key modifier to trigger hole digitizing.  Acceptable values are “altKey”, “shiftKey”, or “ctrlKey”.  If not set, no hole digitizing will take place.  Default is null.

drawingHole

{Boolean} Currently drawing an interior ring.

Constructor

ALKMaps.Handler.Polygon

Create a Polygon Handler.

Parameters

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

Named callbacks

createCalled when a sketch is first created.  Callback called with the creation point geometry and sketch feature.
modifyCalled with each move of a vertex with the vertex (point) geometry and the sketch feature.
pointCalled as each point is added.  Receives the new point geometry.
doneCalled when the point drawing is finished.  The callback will receive a single argument, the polygon geometry.
cancelCalled when the handler is deactivated while drawing.  The cancel callback will receive a geometry.

Functions

createFeature

createFeature: function(pixel)

Add temporary geometries

Parameters

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

addPoint

addPoint: function(pixel)

Add point to geometry.

Parameters

pixel{ALKMaps.Pixel} The pixel location for the new point.

getCurrentPointIndex

getCurrentPointIndex: function()

Returns

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

enforceTopology

enforceTopology: function(event)

Simple topology enforcement for drawing interior rings.  Ensures vertices of interior rings are contained by exterior ring.  Other topology rules are enforced in finalizeInteriorRing to allow drawing of rings that intersect only during the sketch (e.g. a “C” shaped ring that nearly encloses another ring).

finishGeometry

finishGeometry: function()

Finish the geometry and send it back to the control.

finalizeInteriorRing

finalizeInteriorRing: function()

Enforces that new ring has some area and doesn’t contain vertices of any other rings.

cancel

cancel: function()

Finish the geometry and call the “cancel” callback.

restoreFeature

restoreFeature: function(cancel)

Move the feature from the sketch layer to the target layer.

Properties

cancel{Boolean} Cancel drawing.  If falsey, the “sketchcomplete” event will be fired.

destroyFeature

destroyFeature: function(force)

Destroy temporary geometries

Parameters

force{Boolean} Destroy even if persist is true.

drawFeature

drawFeature: function()

Render geometries on the temporary layer.

getSketch

getSketch: function()

Return the sketch feature.

Returns

{ALKMaps.Feature.Vector}

getGeometry

getGeometry: function()

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

Returns

{ALKMaps.Geometry.Polygon}

Vector features use the ALKMaps.Geometry classes as geometry description.
createFeature: function(pixel)
Add temporary geometries
addPoint: function(pixel)
Add point to geometry.
getCurrentPointIndex: function()
{Number} The index of the most recently drawn point.
enforceTopology: function(event)
Simple topology enforcement for drawing interior rings.
finishGeometry: function()
Finish the geometry and send it back to the control.
finalizeInteriorRing: function()
Enforces that new ring has some area and doesn’t contain vertices of any other rings.
cancel: function()
Finish the geometry and call the “cancel” callback.
restoreFeature: function(cancel)
Move the feature from the sketch layer to the target layer.
destroyFeature: function(force)
Destroy temporary geometries
drawFeature: function()
Render geometries on the temporary layer.
getSketch: function()
Return the sketch feature.
getGeometry: function()
Return the sketch geometry.
Handler to draw a path on the map.
Base class to construct a higher-level handler for event sequences.
Controls affect the display or behavior of the map.
This class represents a screen coordinate, in x and y coordinates
Polygon is a collection of Geometry.LinearRings.
Close