Balloon
A balloon is a popup window that can display any HTML content. There is usually just one balloon instance on the map and it is managed via special managers (for example, maps, geo objects, hotspot layers and so on). Don't create them yourself, unless truly necessary.
Constructor | Fields | Events | Methods
Constructor
Balloon(map[, options])
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: Map Reference to a map object. |
— |
Type: Object Options. |
|
true |
Type: Boolean To move the map to show the opened balloon. |
|
false |
Type: Boolean Enables autoscaling when it is impossible to display the map after dragging on the same scale. |
|
500 |
Type: Number The duration of the movement to the point of the balloon (in milliseconds). |
|
34 |
Type: Number|Number[] Offset or offsets from the edges of the visible map area when executing autoPan. The value can be set as a single number (equal margins on all sides), as two numbers (for vertical and horizontal margins), or as four numbers (in the order of upper, right, lower, and left margins). Keep in mind that this value will be added to the value calculated in the margins manager map.margin.Manager. |
|
true |
Type: Boolean Whether to account for map margins map.margin.Manager when executing autoPan. |
|
true |
Type: Boolean Flag for the Close button. |
|
700 |
Type: Number Delay before closing (in ms). |
|
— |
Type: Function|String Layout for balloon content. (Type: constructor for an object with the ILayout interface or the layout key). |
|
— |
Type: String Key for the interactivity model. Available keys and their values are listed in the description of interactivityModel.storage. |
|
islands#balloon |
Type: Function|String External layout for the balloon. (Type: constructor for an object with the ILayout interface or the layout key). |
|
— |
Type: Number Maximum height, in pixels. |
|
— |
Type: Number Maximum width, in pixels. |
|
— |
Type: Number Minimum height, in pixels. |
|
— |
Type: Number Minimum width, in pixels. |
|
— |
Type: Number[] Additional position offset relative to the anchor point. |
|
150 |
Type: Number Delay before opening (in ms). |
|
'balloon' |
Type: String Key of the pane that the balloon overlay is placed in. |
|
null |
Type: Function|String The layout of the balloon contents in the panel mode. If this option is omitted, the value of the contentLayout option is used. (Type: constructor for an object with the ILayout interface or the layout key). |
|
— |
Type: Number The maximum height of the balloon panel. Defined as the coefficient relative to the map height: a number from 0 to 1. |
|
— |
Type: Number The maximum area of the map at which the balloon will be displayed in the panel mode. You can disable panel mode by setting the value to 0, and vice versa, you can always show the balloon in panel mode by setting the value to Infinity. |
|
true |
Type: Boolean Flag for whether there is a shadow. |
|
— |
Type: Function|String Layout for the shadow. (Type: constructor for an object with the ILayout interface or the layout key). |
|
— |
Type: Number[] Additional position offset of the shadow relative to the anchor point. |
|
— |
Type: String The z-index of the balloon. |
* Mandatory parameter/option.
Example:
// Creating an independent balloon instance and displaying it in the center of the map.
var balloon = new ymaps.Balloon(myMap);
// Here map options are set to parent options,
// where they contain default values for mandatory options.
balloon.options.setParent(myMap.options);
// Opening a balloon at the center of the map:
balloon.open(myMap.getCenter());
Fields
Name |
Type |
Description |
Event manager. Inherited from IEventEmitter. |
||
Options manager. Inherited from ICustomizable. |
Events
Name |
Description |
Start of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class. |
|
End of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class. |
|
The event which precedes Balloon.event:userclose. Allows you to cancel the user's action by calling the preventDefault method. Instance of the Event class. |
|
Closing the info object. Inherited from IPopup. |
|
Opening the info object. Inherited from IPopup. |
|
Change to the object options. Inherited from ICustomizable. |
|
Balloon closed by the user. Instance of the Event class. |
Methods
Name |
Returns |
Description |
autoPan() |
Moves the map so that the balloon is visible. Inherited from IBalloon. |
|
Closes the info object. Inherited from IPopup. |
||
getData() |
Returns info object data. Inherited from IPopup. |
|
Returns the promise object to return the overlay. Inherited from IPopup. |
||
Returns the overlay, if one exists. Inherited from IPopup. |
||
Returns the coordinates of the info object. Inherited from IPopup. |
||
isOpen() |
Boolean |
Returns the info object state: open/closed. Inherited from IPopup. |
Opens the info object at the specified position. If the info object is already open, it moves it to the specified point. The format and content of the coordinates is determined by the IProjection that is in the options. Inherited from IPopup. |
||
Defines new data for the info object. Inherited from IPopup. |
||
Specifies a new position for the info object. Inherited from IPopup. |
Events details
autopanbegin
Start of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class.
autopanend
End of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class.
beforeuserclose
The event which precedes Balloon.event:userclose. Allows you to cancel the user's action by calling the preventDefault method. Instance of the Event class.
userclose
Balloon closed by the user. Instance of the Event class.
Mandatory parameter/option.