I
I
Igor Belyaev2016-01-23 17:30:49
JavaScript
Igor Belyaev, 2016-01-23 17:30:49

Yandex.Maps: Opening a balloon on a map with a specified template. How to do?

Essence: When you click on the map, you need to display a balloon with a form. For this, there is, in fact, the template itself (templateLayoutFactory).
To open the balloon, we use:
map.balloon.open(coords, {...});
In the documentation, I found an example of adding my own template:

map.balloon.open(coords, {
    myBodyContent: '<b>body content</b>',
    myFooterContent: 'footer content'
}, {
    contentBodyLayout: ymaps.templateLayoutFactory.createClass('<p>$[myBodyContent]</p>'),
    contentFooterLayout: ymaps.templateLayoutFactory.createClass('<i>$[myFooterContent]</i>')
});

But the balloon still opens with a standard template (with no errors in the console) ... How to be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
forgotten, 2016-01-23
@forgotten

Probably the problem is that the options need to be passed as the third parameter, not the second.
If this is not the case, collect an example on jsfiddle

I
Igor Belyaev, 2016-01-23
@ib2

UPD. Example: https://jsfiddle.net/b3judzxc/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question