behavior.Ruler

Extends IBehavior.

The "Ruler" behavior. For marking points on the map and displaying the distance between them.

Constructor | Fields | Events | Methods

Constructor

behavior.Ruler([options])

Parameters:

Parameter

Default value

Description

options

Type: Object

Options.

options.balloonAutoPan

true

Type: Boolean

Whether to auto-position the map when opening the ruler balloon.

options.balloonAutoPanUseMapMargin

true

Type: Boolean

Whether to account for map margins map.margin.Manager when executing autoPan for the ruler balloon.

Fields

Name

Type

Description

events

IEventManager

Event manager.

Inherited from IEventEmitter.

geometry

geometry.LineString

"Line" behavior geometry.

options

IOptionManager

Options manager.

Inherited from ICustomizable.

Events

Name

Description

disable

Disabling behaviors.

Inherited from IBehavior.

enable

Enabling behaviors.

Inherited from IBehavior.

optionschange

Change to the object options.

Inherited from ICustomizable.

parentchange

The parent object reference changed.

Data fields:

  • oldParent - Old parent.
  • newParent - New parent.

Inherited from IChild.

Methods

Name

Returns

Description

close()

Boolean

Deletes all the points on the ruler. If the current number of points is more than two, confirmation of this action will be requested.

disable()

Disables the behavior.

Inherited from IBehavior.

enable()

Enables the behavior.

Inherited from IBehavior.

getParent()

IParentOnMap|null

Returns link to the parent object, or null if the parent element was not set.

Inherited from IChildOnMap.

getState()

String

The ruler state is described by a string consisting of sequences separated by the "~" symbol. Each sequence is a substring in the format "longitude,latitude" that describes the increment in coordinates relative to the previous ruler point.

isEnabled()

Boolean

Checks whether the behavior is enabled.

Inherited from IBehavior.

setParent(parent)

IChildOnMap

Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object.

Inherited from IChildOnMap.

setState(state)

Retrieves the ruler state from the encoded string. See behavior.Ruler.getState.

Fields details

geometry

{geometry.LineString} geometry

"Line" behavior geometry.

Example:

// Setting coordinates of the first point on the ruler.
myMap.behaviors.get('ruler').geometry.set(0, [0, 0]);

Methods details

close

{Boolean} close()

Deletes all the points on the ruler. If the current number of points is more than two, confirmation of this action will be requested.

Returns true, if the action was completed successfully.

getState

{String} getState()

The ruler state is described by a string consisting of sequences separated by the "~" symbol. Each sequence is a substring in the format "longitude,latitude" that describes the increment in coordinates relative to the previous ruler point.

Returns the current state of the ruler, in encoded format.

setState

{} setState(state)

Retrieves the ruler state from the encoded string. See behavior.Ruler.getState.

Parameters:

Parameter

Default value

Description

state*

Type: String

Encoded state of the ruler.

* Mandatory parameter/option.