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

collection*

Type: IReadOnlyCollection

Collection of objects.

* Mandatory parameter/option.

Fields

Name

Type

Description

events

IEventManager

Event manager.

Inherited from IEventEmitter.

Events

Name

Description

autopanbegin

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.

autopanend

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.

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. Names of fields that are available via the Event.get method:

Inherited from IBalloonManager.

close

Closing the info object. Names of fields available via Event.get:

  • target - Reference to the object where the closing occurred.

Inherited from IPopupManager.

open

Opening the info object. Names of fields available via Event.get:

  • target - Reference to the object where the opening occurred.

Inherited from IPopupManager.

userclose

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()

vow.Promise

Moves the map so that the balloon is visible.

Inherited from IBalloonManager.

close([force])

vow.Promise

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.

getOptions()

IOptionManager|null

Returns the options manager or 'null'.

Inherited from IPopupManager.

getOverlay()

vow.Promise

Returns the promise object to return the overlay.

Inherited from IPopupManager.

getOverlaySync()

IOverlay|null

Returns the overlay, if one exists.

Inherited from IPopupManager.

getPosition()

Number[]|null

Returns the coordinates of the info object or 'null'.

Inherited from IPopupManager.

isOpen(id)

Boolean

A method that detects whether the balloon is open on the object with the passed identifier.

open(objectId, anchorPixelPosition)

vow.Promise

Opens the balloon on the object with the passed identifier.

setData(objectData)

vow.Promise

Sets new data for displaying the balloon.

setOptions(options)

vow.Promise

Defines new options for the info object.

Inherited from IPopupManager.

setPosition(position)

vow.Promise

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

force

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

id*

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

objectId*

Type: Object

ID of the object to open the balloon on.

anchorPixelPosition*

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

objectData*

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);
            }
        });
    }
});