M
M
Maxim2015-09-01 15:04:47
Yandex
Maxim, 2015-09-01 15:04:47

How to center the balloon?

How to center the balloon relative to the label?
here is a
screenshot joxi.ru/MAjRoEBhp7x6Ae

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Reenko, 2015-09-08
@Reenko

The documentation has an example in which the "tail" is in the center of the balloon and points to the mark.
https://tech.yandex.ru/maps/jsbox/2.1/balloon_autopan
(code from documentation)

/**
 * Сдвигаем балун, чтобы "хвостик" указывал на точку привязки.
 * @see https://api.yandex.ru/maps/doc/jsapi/2.1/ref/reference/IBalloonLayout.xml#event-userclose
 * @function
 * @name applyElementOffset
 */
applyElementOffset: function () {
    this._$element.css({
        left: -(this._$element[0].offsetWidth / 2),
        top: -(this._$element[0].offsetHeight + this._$element.find('.arrow')[0].offsetHeight)
    });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question