Documentation
Reference
2.1.55 (current version)
collection
interactivityModel
Interfaces

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:

ParameterDefault valueDescription
options

Type: Object

Options.

options.balloonAutoPan true

Type: Boolean

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

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

geometrygeometry.LineString

"Line" behavior geometry.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

Events

NameDescription
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

NameReturnsDescription
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()

IControlParent|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

"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:

ParameterDefault valueDescription
state*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String

Encoded state of the ruler.

* Mandatory parameter/option.