Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.52 (release candidate)
collection
interactivityModel
Interfaces

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:

ParameterDefault valueDescription
collection *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IReadOnlyCollection

Collection of objects.

* Mandatory parameter/option.

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

Events

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

NameReturnsDescription
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:

ParameterDefault valueDescription
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:

ParameterDefault valueDescription
id*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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

Opens the balloon on the object with the passed identifier.

Returns Promise object.

Parameters:

ParameterDefault valueDescription
objectId*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object

ID of the object to open the balloon on.

anchorPixelPosition*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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

Sets new data for displaying the balloon.

Returns Promise object.

Parameters:

ParameterDefault valueDescription
objectData*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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