Handler to draw a regular polygon on the map. Polygon is displayed on mouse down, moves or is modified on mouse move, and is finished on mouse up. The handler triggers callbacks for ‘done’ and ‘cancel’. Create a new instance with the ALKMaps.Handler.RegularPolygon constructor.
ALKMaps. | Handler to draw a regular polygon on the map. |
Properties | |
sides | {Integer} Number of sides for the regular polygon. |
radius | {Float} Optional radius in map units of the regular polygon. |
snapAngle | {Float} If set to a non-zero value, the handler will snap the polygon rotation to multiples of the snapAngle. |
snapToggle | {String} If set, snapToggle is checked on mouse events and will set the snap mode to the opposite of what it currently is. |
layerOptions | {Object} Any optional properties to be set on the sketch layer. |
persist | {Boolean} Leave the feature rendered until clear is called. |
irregular | {Boolean} Draw an irregular polygon instead of a regular polygon. |
citeCompliant | {Boolean} If set to true, coordinates of features drawn in a map extent crossing the date line won’t exceed the world bounds. |
angle | {Float} The angle from the origin (mouse down) to the current mouse position, in radians. |
fixedRadius | {Boolean} The polygon has a fixed radius. |
feature | {ALKMaps.Feature.Vector} The currently drawn polygon feature |
layer | {ALKMaps.Layer.Vector} The temporary drawing layer |
origin | {ALKMaps.Geometry.Point} Location of the first mouse down |
Constructor | |
ALKMaps. | Create a new regular polygon handler. |
Functions | |
setOptions | |
activate | Turn on the handler. |
deactivate | Turn off the handler. |
down | Start drawing a new feature |
move | Respond to drag move events |
up | Finish drawing the feature |
out | Finish drawing the feature. |
createGeometry | Create the new polygon geometry. |
modifyGeometry | Modify the polygon geometry in place. |
calculateAngle | Calculate the angle based on settings. |
cancel | Finish the geometry and call the “cancel” callback. |
finalize | Finish the geometry and call the “done” callback. |
clear | Clear any rendered features on the temporary layer. |
callback | Trigger the control’s named callback with the given arguments |
{String} If set, snapToggle is checked on mouse events and will set the snap mode to the opposite of what it currently is. To disallow toggling between snap and non-snap mode, set freehandToggle to null. Acceptable toggle values are ‘shiftKey’, ‘ctrlKey’, and ‘altKey’. Snap mode is only possible if this.snapAngle is set to a non-zero value.
{Boolean} Draw an irregular polygon instead of a regular polygon. Default is false. If true, the initial mouse down will represent one corner of the polygon bounds and with each mouse movement, the polygon will be stretched so the opposite corner of its bounds follows the mouse position. This property takes precedence over the radius property. If set to true, the radius property will be ignored.
{ALKMaps.Feature.Vector} The currently drawn polygon feature
{ALKMaps.Layer.Vector} The temporary drawing layer
{ALKMaps.Geometry.Point} Location of the first mouse down
Create a new regular polygon handler.
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 object with properties to be set on the handler. If the options.sides property is not specified, the number of sides will default to 4. |
create | Called when a sketch is first created. Callback called with the creation point geometry and sketch feature. |
done | Called when the sketch drawing is finished. The callback will receive a single argument, the sketch geometry. |
cancel | Called when the handler is deactivated while drawing. The cancel callback will receive a geometry. |
calculateAngle: function( point, evt )
Calculate the angle based on settings.
point | {ALKMaps.Geometry.Point} |
evt | {Event} |
callback: function ( name, args )
Trigger the control’s named callback with the given arguments
name | {String} The key for the callback that is one of the properties of the handler’s callbacks object. |
args | {Array} An array of arguments with which to call the callback (defined by the control). |
setOptions: function ( newOptions )
Turn on the handler.
activate: function()
Turn off the handler.
deactivate: function()
Start drawing a new feature
down: function( evt )
Respond to drag move events
move: function( evt )
Finish drawing the feature
up: function( evt )
Finish drawing the feature.
out: function( evt )
Create the new polygon geometry.
createGeometry: function()
Modify the polygon geometry in place.
modifyGeometry: function()
Calculate the angle based on settings.
calculateAngle: function( point, evt )
Finish the geometry and call the “cancel” callback.
cancel: function()
Finish the geometry and call the “done” callback.
finalize: function()
Clear any rendered features on the temporary layer.
clear: function()
Trigger the control’s named callback with the given arguments
callback: function ( name, args )