Class: DistanceTool

OM.tool. DistanceTool


new DistanceTool(map, options)

A DistanceTool can be used to measure linear distances on the map by drawing
a series of connected line segments. It is a subclass of OM.tool.Tool.

Parameters:
Name Type Description
map OM.Map

The map instance to be associated with this tool

options object

This is an object literal that specifies the initial DistanceTool options. It can have the following properties.


  • unit {String} Optional. The unit for the distance tool.
  • transformToGeodetic {boolean} Optional. If true, transform To Geodetic; default value is true.
  • dataSource {String} Optional. The datasource for the distance tool.If client side supports the srid transform,this param is not required,
    if client side does not support the srid transform,this param is required.
Returns:

An instance of OM.tool.DistanceTool

Type
OM.tool.DistanceTool

Extends

Methods


clear()

Clear the tool's generated shapes and state.


getSegmentsArray()

Get the line segments distance between each neighboring point.The sequence of the segments distance array is the same as the point you add in sequence.

Returns:

An array of the line segments distance.

Type
Array

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

getTotalDistance()

Get the total distance of the line.

Returns:

The total distance of the line.

Type
float

on()

A shorthand name for the member function addListener.

Inherited From:
Mixes In:

setDrawingStyle(options)

Set a drawing style for the tool. The style used to display the vertices and line segments.
This function should be called once to set the style for the vertices (i.e. the point style) and
once to set the style for the line segments.

Parameters:
Name Type Description
options int

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


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

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

Overrides:
Returns:
Type
void

setStyle(style)

Set rendering style for the completed linestring

Parameters:
Name Type Description
style OM.style.Line

The line style to use.

Overrides:
Returns:
Type
OM.tool.DistanceTool

start()

Start the tool.

Returns:
Type
void