Hello. Help to understand the issue of adding your template for the balun. I read a lot of documentation and questions, but I encounter a problem that I cannot understand. More precisely what I'm doing wrong.

There is a map. Tags add from JSON using objectManager

I expose objectManager.objects.options.set ('balloonLayout', 'MyBalloonLayout');

When I click on the label, I don’t get an open balun using a custom template, but I get an error in the console: Uncaught TypeError: Cannot read property 'getModuleSync' of null

var MyBalloonContentLayout = ymaps.templateLayoutFactory.createClass( '<h3>$[properties.balloonContentHeader]</h3>' + '<div>$[properties.balloonContentBody]</div>' + '<div> <a href="#" id="more">Подробнее</a></div>', { build: function() { MyBalloonContentLayout.superclass.build.call(this); $('#more').bind('click', this.onMoreClick); }, clear: function() { $('#more').unbind('click', this.onMoreClick); MyBalloonContentLayout.superclass.clear.call(this); }, onMoreClick: function() { alert('УРА'); } } ); // Добавляю опцию для балуна objectManager.objects.options.set('balloonContentLayout', 'MyBalloonContentLayout'); 

Link to sample code: https://codepen.io/anon/pen/mpyeRd?editors=1010

Please help me figure it out.

    1 answer 1

    Good day. The error is that we have specified as the value of the option not the class MyBalloonContentLayout, but the line 'MyBalloonContentLayout'. The maps API treats a line as the name of a layout from a set of standard ones. There is no standard layout under the 'MyBalloonContentLayout' key - an error occurs (incomprehensible, yes).

    You just need to remove the quotes when setting the objectManager.objects.options.set('balloonContentLayout', MyBalloonContentLayout); option objectManager.objects.options.set('balloonContentLayout', MyBalloonContentLayout);

    • Thank you very much, it really works. And thanks for the explanation. - Alexander