objectManager.Balloon
Extends IBalloonManager.
Manager for the collection balloon ObjectManager. Allows to manage the object's balloon by opening it and hiding it. It uses the map balloon manager map.Balloon. Collections of objects in ObjectManager contain an instance of this class, accessible as myObjectManager.objects.balloon and myObjectsLayer.clusters.balloon. Don't create new instances of this class unless necessary.
See Balloon
Constructor | Fields | Events | Methods
Constructor
objectManager.Balloon(collection)
Parameters:
Parameter |
Default value |
Description |
— |
Type: IReadOnlyCollection Collection of objects. |
* Mandatory parameter/option.
Fields
Name |
Type |
Description |
Event manager. Inherited from IEventEmitter. |
Events
Name |
Description |
Start of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IBalloonManager. |
|
End of automatic shifting of the map center initiated by the autoPan method. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IBalloonManager. |
|
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. Names of fields that are available via the Event.get method:
Inherited from IBalloonManager. |
|
Closing the info object. Names of fields available via Event.get:
Inherited from IPopupManager. |
|
Opening the info object. Names of fields available via Event.get:
Inherited from IPopupManager. |
|
Balloon closed by the user. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IBalloonManager. |
Methods
Name |
Returns |
Description |
autoPan() |
Moves the map so that the balloon is visible. Inherited from IBalloonManager. |
|
Closes an open balloon. |
||
destroy() |
Disables the info object manager. Inherited from IPopupManager. |
|
getData() |
Object|null |
Returns hash describing the object the balloon is open on, or null if the balloon was not opened. |
IOptionManager|null |
Returns the options manager or 'null'. Inherited from IPopupManager. |
|
Returns the promise object to return the overlay. Inherited from IPopupManager. |
||
IOverlay|null |
Returns the overlay, if one exists. Inherited from IPopupManager. |
|
Number[]|null |
Returns the coordinates of the info object or 'null'. Inherited from IPopupManager. |
|
Boolean |
A method that detects whether the balloon is open on the object with the passed identifier. |
|
Opens the balloon on the object with the passed identifier. |
||
Sets new data for displaying the balloon. |
||
Defines new options for the info object. Inherited from IPopupManager. |
||
Specifies a new position for the info object. Inherited from IPopupManager. |
Methods details
close
{vow.Promise} close([force])
Closes an open balloon.
Returns Promise object.
Parameters:
Parameter |
Default value |
Description |
false |
Type: Boolean Instant closure. |
Example:
// Closing all balloons on the layer.
objectManager.objects.balloon.close();
objectManager.clusters.balloon.close();
getData
{Object|null} getData()
Returns hash describing the object the balloon is open on, or null if the balloon was not opened.
Example:
var cluster = objectManager.clusters.balloon.getData();
if (cluster) {
alert('The balloon for a cluster of ' + cluster.properties.geoObjects.length + ' objects is currently opened.');
}
isOpen
{Boolean} isOpen(id)
A method that detects whether the balloon is open on the object with the passed identifier.
Returns balloon state: open/closed.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: Object Object ID. |
* Mandatory parameter/option.
Example:
// Closing the ballon after the second click on the placemark.
objectManager.objects.options.set('hideIconOnBalloonOpen', false);
objectManager.objects.events.add('click', function (e) {
var objectId = e.get('objectId');
if (objectManager.objects.balloon.isOpen(objectId)) {
objectManager.objects.balloon.close();
}
});
open
{vow.Promise} open(objectId, anchorPixelPosition)
Opens the balloon on the object with the passed identifier.
Returns Promise object.
Parameters:
Parameter |
Default value |
Description |
— |
Type: Object ID of the object to open the balloon on. |
|
— |
Type: |
* Mandatory parameter/option.
Example:
// Loading the object data before opening the balloon.
// Disabling automatic balloon opening by clicking on the object.
objectManager.options.set('geoObjectOpenBalloonOnClick', false);
objectManager.objects.events.add('click', function (e) {
var objectId = e.get('objectId');
// Preloading the object data after the object was clicked.
loadObjectData(objectId).then(function (data) {
// As soon as the data is ready, we're assigning it to the object and opening the balloon.
objectManager.objects.getById(objectId).properties = data;
objectManager.objects.balloon.open(objectId);
});
});
setData
{vow.Promise} setData(objectData)
Sets new data for displaying the balloon.
Returns Promise object.
Parameters:
Parameter |
Default value |
Description |
— |
Type: Object Hash with a description of the object to open the balloon on. Corresponds to the object description that is input to ObjectManager.add. |
* Mandatory parameter/option.
Example:
// Preloading the object data after the ballon is opened on the object.
objectManager.objects.events.add('balloonopen', function (e) {
var objectId = e.get('objectId'),
object = objectManager.objects.getById(objectId);
if (!object.properties) {
loadObjectData(objectId).then(function (data) {
if (objectManager.balloon.isOpen(objectid)) {
object.properties = data;
objectManager.objects.balloon.setData(object);
}
});
}
});
Mandatory parameter/option.