control.TypeSelector
Extends control.ListBox.
The "Map types" control. For this control, you can add list items that describe map types, as well as additional elements. The key of the control in the storage. control.storage — "typeSelector".
Constructor | Fields | Events | Methods
Constructor
control.TypeSelector([parameters])
Parameters:
Parameter |
Default value |
Description |
— |
Type: String[]|MapType[]|Object Object with descriptions of control parameters. If an array is passed, it is interpreted as an array of map types. |
|
— |
Type: String[]|MapType[] Array of constructors for map types or keys. If the parameter is omitted, the item is added to the standard set of map types. List of available map types:
|
|
— |
Type: Object Control options. |
|
false |
Type: Boolean Whether the control registers its size in the map margins manager map.margin.Manager. |
|
true |
Type: Boolean This flag enables to collapse the list when the button loses focus. For example, when a user clicks on the document. |
|
3000 |
Type: Number Time delay, after which the open list closes automatically. |
|
true |
Type: Boolean Flag that allows automatically expanding/collapsing the list when clicked. |
|
"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 one by one, 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. |
|
200 |
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". |
|
— |
Type: Function|String Constructor of the control layout which implements the ISelectableControlLayout and IGroupControlLayout interfaces or the layout key in the layout.storage. The layout constructor is passed an object containing the fields:
|
|
[30, 65, 85] |
Type: Number|Number[] The maximum width of the listbox in different states. If a number is specified, it is assumed that the button has the same maximum dimensions in all states. If an array is specified, it will be interpreted as the maximum width of the button in different states, from the lesser to the greater. |
|
'ifMercator' |
Type: String Shows or hides the "Panoramas" element. Possible values:
|
|
— |
Type: Object Object describing the position of a control. If the position option is set, the float option value is automatically treated as "none". |
|
'auto' |
Type: Number|String Position relative to the bottom edge of the map. |
|
'auto' |
Type: Number|String Position relative to the left edge of the map. |
|
'auto' |
Type: Number|String Position relative to the right edge of the map. |
|
'auto' |
Type: Number|String Position relative to the top edge of the map. |
|
true |
Type: Boolean Indicates if the control is displayed. |
|
— |
Type: Object State of the control. |
|
false |
Type: Boolean Flags if the list is expanded. |
Example:
map.controls.add(new ymaps.control.TypeSelector(['yandex#map', 'yandex#hybrid']));
Fields
Name |
Type |
Description |
Control data. |
||
Event manager. Inherited from IEventEmitter. |
||
Options manager. Inherited from IControl. |
||
State of the drop-down list. Names of fields that are available via the data.Manager.get method:
Inherited from control.ListBox. |
Events
Name |
Description |
A child object was added. Inherited from ICollection. |
|
Clicking the list title. Instance of the Event class. Inherited from control.ListBox. |
|
The list is closed. Instance of the Event class. Inherited from control.ListBox. |
|
The list is open. Instance of the Event class. Inherited from control.ListBox. |
|
Change to the object options. Inherited from ICustomizable. |
|
The parent object reference changed. Data fields:
Inherited from IChild. |
|
The event indicating that the button has been pressed. Unlike the click event, it is generated only if the state isEnabled == true. Instance of the Event class. Inherited from control.ListBox. |
|
A child object was deleted. Inherited from ICollection. |
Methods
Name |
Returns |
Description |
Adds a child object to the collection. Inherited from ICollection. |
||
Adds a map type to the list. |
||
collapse() |
Collapses the list. Inherited from control.ListBox. |
|
expand() |
Expands the list. Inherited from control.ListBox. |
|
Returns iterator for the collection. Inherited from ICollection. |
||
getMap() |
Returns reference to the map. |
|
IControlParent|null |
Returns link to the parent object, or null if the parent element was not set. Inherited from IControl. |
|
Boolean |
Returns a flag for whether the control is in the expanded state. Inherited from control.ListBox. |
|
Removes a child object from the collection. Inherited from ICollection. |
||
Deletes all map types from the control. |
||
Deletes the map type. |
||
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
data
{data.Manager} data
Control data.
Methods details
addMapType
{control.TypeSelector} addMapType(mapType[, positionIndex])
Adds a map type to the list.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
— |
Type: String|MapType Map type. |
|
— |
Type: Integer Position in the list (if omitted, the new map type is added to the end of the list). The list of default positionIndex values for standard map types:
|
* Mandatory parameter/option.
Examples:
1.
var typeSelector = new ymaps.control.TypeSelector([]);
typeSelector.addMapType('yandex#map', 1);
typeSelector.addMapType('yandex#hybrid', 0);
2.
// If a standard set of map types is being used,
// and we want to add our own set from mapType.storage // and insert it between "satellite" and "map".
var typeSelector = myMap.controls.get('typeSelector');
typeSelector.addMapType('my#mapType', 6);
getMap
{Map} getMap()
Returns reference to the map.
removeAllMapTypes
{control.TypeSelector} removeAllMapTypes()
Deletes all map types from the control.
Returns self-reference.
removeMapType
{control.TypeSelector} removeMapType(mapType)
Deletes the map type.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
— |
Type: String|MapType Map type. |
* Mandatory parameter/option.
Mandatory parameter/option.