Class: RedlineTool

OM.tool. RedlineTool


new RedlineTool(map, geoType, options)

This is a sub class of OM.tool.Tool that can be used to draw arbitrary
shape(s) on the map. It is similar to the traditional red-lining function.

Parameters:
Name Type Description
map OM.Map

A map object

geoType int

The geometry type. Must be one of the following pre-defined constants
OM.tool.RedlineTool.TYPE_POINT,
OM.tool.RedlineTool.TYPE_LINESTRING, or
OM.tool.RedlineTool.TYPE_POLYGON defined in this class.

options Object

It may contain the following attributes that specify the redline tool mode.


  • finishMode {Boolean}: default is OM.tool.Redline.FINISH_ON_CLICK, meaning you must click on the initial
    polygon vertex once to finish/complete the tool's drawing operation. If set to OM.tool.Redline.FINISH_ON_RELEASE, then
    the tool will complete the drawing on the very first mouse-up.

  • simplified {Boolean}: default is true. true: simplify the result of the redline; false: not simplify the result of redline

Returns:

An instance of OM.tool.RedlineTool

Type
OM.tool.RedlineTool

Extends

Methods


addVertex(index, vertex, isRedo)

This method adds a new shape point.

Parameters:
Name Type Description
index int

Indicates the position, starting from 0, to put the new point in. If null, the point will be added to the end of the shape.

vertex Object

Either an OM.geometry.Point or any object with x and y member variables. If it is the former, the coordinates will be read as ground coordinates (srid transformation applied if necessary), the latter as screen coordinates.

isRedo bool

Optional If set to true the edit won't generate an entry in the undo manager.


clear()

Clear the tool's generated shapes and resets the state.

Returns:
Type
void

getGeometry()

Returns the geometry that has been created by this tool.

Overrides:
Returns:

The geometry created by this tool; or null if none has been created.

Type
OM.geometry.Geometry

getGeometryType()

Returns the type of geometry that can be created by this Redline Tool instance.

Returns:

an geometry type such as RedlineTool.TYPE_POINT, TYPE_LINESTRING or TYPE_POLYGON.

Type
number

getStatus()

Get the tool's status. Can be one of OM.tool.Tool.STARTED, OM.tool.Tool.STOPPED, or OM.tool.Tool.FINISHED

Inherited From:
Returns:

tool status

Type
int

on()

A shorthand name for the member function addListener.

Inherited From:
Mixes In:

removeVertex(index, isRedo)

This method removes a shape point.

Parameters:
Name Type Description
index int

Indicates the position of the point to remove, starting from 0.

isRedo bool

Optional If set to true, the edit won't generate an entry in the undo manager.


setDrawingStyle(options)

Set a drawing style for the tool. Should be called twice, once to set the point style for vertices
and once to set the line style for the segments.

Parameters:
Name Type Description
options int

An object with two properties, type and style, which
define the geometry type and the style.


  • type Specifies the geometry type. Must be one of two pre-defined constants:
    OM.tool.RedlineTool.TYPE_POINT or OM.tool.RedlineTool.TYPE_LINESTRING.

  • style {OM.style.Style} The style to use

Overrides:
Returns:
Type
void

setStyle(options)

Set rendering style for the completed feature.

Parameters:
Name Type Description
options int

An object with two properties, type and style, which
define the geometry type and the style.


  • type Specifies the geometry type. Must be one of three pre-defined constants:
    OM.tool.RedlineTool.TYPE_POINT, OM.tool.RedlineTool.TYPE_LINESTRING, or
    OM.tool.RedlineTool.TYPE_POLYGON

  • style {OM.style.Style} The style to use

Overrides:
Returns:
Type
OM.tool.RedlineTool