control.RouteButton

Extends IControl, ICustomizable.

The Route Button control: button with route panel in the popup. The key of the control in the storage control.storage — "routeButtonControl".

Constructor | Fields | Events | Methods

Constructor

control.RouteButton([parameters])

Parameters:

Parameter

Default value

Description

parameters

Type: Object

Control parameters.

parameters.lazy

true

Type: Boolean

If set to true, all modules needed to work with routes will be loaded lazily when the user opens the panel the first time.

parameters.options

Type: Object

Control options. Use the 'routePanel' prefix to configure underlying IRoutePanel options.

parameters.options.adjustMapMargin

false

Type: Boolean

Whether the control registers its size in the map margins manager map.margin.Manager.

parameters.options.autofocus

true

Type: Boolean

Specifies whether route panel must automatically gain focus when popup opens.

parameters.options.collapseOnBlur

true

Type: Boolean

This flag enables to collapse the panel when the control loses focus.

parameters.options.float

"right"

Type: String

The side to which you want to align the control. Can take three values: "left", "right" or "none". If set to "left" or "right", the controls are arranged in a line, starting from the left or right edge of the map, respectively. If set to "none", the controls are positioned according to the values of the left, right, bottom and top options, relative to the boundaries of the map. See also the description of the position option.

parameters.options.floatIndex

0

Type: Number

The priority of the control positioning. The element with highest priority is positioned closer to the map boundary that is specified in the float property. Does not work with float = "none".

parameters.options.popupAnimate

true

Type: Boolean

This flag indicates whether popup expansion and collapse should be animated.

parameters.options.popupFloat

'auto'

Type: Boolean

Specifies which button edge the popup should stick to. Takes the following values:

  • 'auto' - The side depends on the size of the map and the size of the popup.
  • 'right' - The right side of the popup sticks to the right side of the control.
  • 'left' - The left side of the popup sticks to the left side of the control.

parameters.options.popupWidth

'210px'

Type: String

Specifies CSS width of popup. Width is restricted by 176px below and 400px above.

parameters.options.position

Type: Object

Object describing the position of a control.

parameters.options.position.bottom

'auto'

Type: Number|String

Position relative to the bottom edge of the map.

parameters.options.position.left

10

Type: Number|String

Position relative to the left edge of the map.

parameters.options.position.right

'auto'

Type: Number|String

Position relative to the right edge of the map.

parameters.options.position.top

108

Type: Number|String

Position relative to the top edge of the map.

parameters.options.size

'auto'

Type: String

Defines the appearance of the control. Takes the following values:

  • 'auto' - The layout is changed automatically depending on the dimensions of the map and the number of added controls.
  • 'small' - The layout displays the icon, regardless of the map size.
  • 'medium' - The layout displays only text, regardless of the map size.
  • 'large' - The layout always displays both the icon and text, regardless of the map size.

parameters.options.visible

true

Type: Boolean

Indicates if the control is displayed.

parameters.state

Type: Object

Object describing the state of a control.

parameters.state.expanded

false

Type: Boolean

Indicates whether the popup with the panel is expanded.

Examples:

1.

// Example 1.
// Creating a RouteButton control and adding it to the map.
var routeButton = new ymaps.control.RouteButton({
    options: {
        size: "small"
    }
});
myMap.controls.add(routeButton);

2.

// Example 2.
// Add control to the left corner of the map and set default points of arrival and departure.
myMap.controls.add('routeButtonControl', {
    size: "large",
    float: "left",
    floatIndex: 1000,
});
myMap.controls.get('routeButtonControl').routePanel.state.set({
    fromEnabled: false,
    from: "moscow",
    to: "saint petersburg",
    type: "auto"
});

Fields

Name

Type

Description

events

IEventManager

Event manager.

Inherited from IEventEmitter.

options

IOptionManager

Options manager.

Inherited from IControl.

routePanel

IRoutePanel

Events

Name

Description

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

getParent()

IControlParent|null

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

Inherited from IControl.

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 IControl.

Fields details

routePanel

{IRoutePanel} routePanel