JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://yandex.st/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="http://api-maps.yandex.ru/2.0/?lang=ru-RU&load=package.full" type="text/javascript"></script>
<body>
<div id="YMapsID"></div>
</body>
CSS
#YMapsID {
width: 800px;
height: 600px;
}
.cluster-balloon-item {margin-top: 10px; cursor: pointer;}
.cluster-balloon-item:hover {color: blue;}
.cluster-balloon-item-bold {font-weight: bold;}
JavaScript
ymaps.ready(function () {
var myMap = window.map = new ymaps.Map('YMapsID', {
center: [55.751574, 37.573856],
zoom: 9,
behaviors: ['default', 'scrollZoom']
}),
MainContentLayout = ymaps.templateLayoutFactory.createClass('', {
build: function () {
MainContentLayout.superclass.build.call(this);
this.stateListener = this.getData().state.events.group()
.add('change', this.onStateChange, this);
this.activeObject = this.getData().state.get('activeObject');
this.applyContent();
},
clear: function () {
if (this.activeObjectLayout) {
this.activeObjectLayout.setParentElement(null);
this.activeObjectLayout = null;
}
this.stateListener.removeAll();
MainContentLayout.superclass.clear.call(this);
},
onStateChange: function () {
var newActiveObject = this.getData().state.get('activeObject');
if (newActiveObject != this.activeObject) {
this.activeObject = newActiveObject;
this.applyContent();
}
var target = this.activeObject;
var viewed = target.properties.get('viewed');
if (!viewed) {
target.properties.set('viewed', true);
var currentCluster = this.getData().cluster;
var viewedNumbers = currentCluster.properties.get('viewedNumbers')
currentCluster.properties.set('viewedNumbers', viewedNumbers+1);
}
},
applyContent: function () {
if (this.activeObjectLayout) {
this.activeObjectLayout.setParentElement(null);
}
...