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 |
— |
Type: Object Options. |
|
true |
Type: Boolean Whether to auto-position the map when opening the ruler balloon. |
|
true |
Type: Boolean Whether to account for map margins map.margin.Manager when executing autoPan for the ruler balloon. |
Fields
Name |
Type |
Description |
Event manager. Inherited from IEventEmitter. |
||
"Line" behavior geometry. |
||
Options manager. Inherited from ICustomizable. |
Events
Name |
Description |
Disabling behaviors. Inherited from IBehavior. |
|
Enabling behaviors. Inherited from IBehavior. |
|
Change to the object options. Inherited from ICustomizable. |
|
The parent object reference changed. Data fields:
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. |
|
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. |
Boolean |
Checks whether the behavior is enabled. Inherited from IBehavior. |
|
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. |
||
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 |
— |
Type: String Encoded state of the ruler. |
* Mandatory parameter/option.
Mandatory parameter/option.