# OpenLayers.Handler.RegularPolygon

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 OpenLayers.Handler.RegularPolygon constructor.

#### Inherits from

- OpenLayers.Handler.Drag

Summary

OpenLayers.Handler.RegularPolygon | 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.
persist | {Boolean} Leave the feature rendered until clear is called.
irregular | {Boolean} Draw an irregular polygon instead of a regular polygon.
Constructor |
OpenLayers.Handler.RegularPolygon | Create a new regular polygon handler.
Functions |
setOptions |
activate | Turn on the handler.
deactivate | Turn off the handler.
cancel | Finish the geometry and call the “cancel” callback.
clear | Clear any rendered features on the temporary layer.

### Properties

### sides

{Integer} Number of sides for the regular polygon. Needs to be greater than 2. Defaults to 4.

### radius

{Float} Optional radius in map units of the regular polygon. If this is set to some non-zero value, a polygon with a fixed radius will be drawn and dragged with mose movements. If this property is not set, dragging changes the radius of the polygon. Set to null by default.

### snapAngle

{Float} If set to a non-zero value, the handler will snap the polygon rotation to multiples of the snapAngle. Value is an angle measured in degrees counterclockwise from the positive x-axis.

### snapToggle

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

### persist

{Boolean} Leave the feature rendered until clear is called. Default is false. If set to true, the feature remains rendered until clear is called, typically by deactivating the handler or starting another drawing.

### irregular

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

### Constructor

### OpenLayers.Handler.RegularPolygon

Create a new regular polygon handler.

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

#### Named callbacks

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 recieve a single argument, the sketch geometry.
cancel | Called when the handler is deactivated while drawing. The cancel callback will receive a geometry.

### Functions

### setOptions

> setOptions: function ( | newOptions | )

#### Parameters

newOptions | {Object}

### activate

> activate: function()

Turn on the handler.

#### Return

{Boolean} The handler was successfully activated

### deactivate

> deactivate: function()

Turn off the handler.

#### Return

{Boolean} The handler was successfully deactivated

### cancel

> cancel: function()

Finish the geometry and call the “cancel” callback.

### clear

> clear: function()

Clear any rendered features on the temporary layer. This is called when the handler is deactivated, canceled, or done (unless persist is true).

> setOptions: function ( | newOptions | )

> activate: function()

Turn on the handler.

> deactivate: function()

Turn off the handler.

> cancel: function()

Finish the geometry and call the “cancel” callback.

> clear: function()

Clear any rendered features on the temporary layer.
Create a new regular polygon handler.
The drag handler is used to deal with sequences of browser events related to dragging.
Controls affect the display or behavior of the map.
Close