Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var places = [];
- groups.forEach(function (grp) {
- grp.items.forEach(function (plc) {
- places.push(plc)
- });
- });
- // Создаем собственный макет с информацией о выбранном геообъекте.
- var customItemContentLayout = ymaps.templateLayoutFactory.createClass(
- // Флаг "raw" означает, что данные вставляют "как есть" без экранирования html.
- '<h2 class=ballon_header>{{ properties.balloonContentHeader|raw }}</h2>' +
- '<img class=balloon_img>{{properties.balloonImage|raw }}</img>'+
- '<div class=ballon_body>{{ properties.balloonContentBody|raw }}</div>' +
- '<div class=ballon_footer>{{ properties.balloonContentFooter|raw }}</div>'
- );
- var clusterer = new ymaps.Clusterer({
- clusterDisableClickZoom: true,
- clusterOpenBalloonOnClick: true,
- // Устанавливаем режим открытия балуна.
- // В данном примере балун никогда не будет открываться в режиме панели.
- clusterBalloonPanelMaxMapArea: 0,
- // Устанавливаем размер макета контента балуна (в пикселях).
- clusterBalloonContentLayoutWidth: 500,
- // Устанавливаем собственный макет.
- clusterBalloonItemContentLayout: customItemContentLayout,
- // Устанавливаем ширину левой колонки, в которой располагается список всех геообъектов кластера.
- clusterBalloonLeftColumnWidth: 120
- });
- // Заполняем кластер геообъектами со случайными позициями.
- getPointData = function (index) {
- return {
- balloonImage: places[index].img,
- balloonContentHeader: places[index].name,
- balloonContentBody: places[index].Body,
- balloonContentFooter: places[index].Footer,
- clusterCaption: '<strong>' + places[index].name + '</strong>'
- };
- },
- getPointOptions = function () {
- return {
- preset: 'islands#redIcon'
- };
- },
- points = [];
- groups.forEach(function (grp) {
- grp.items.forEach(function (plc) {
- points.push(
- plc.center
- );
- });
- });
- geoObjects = [];
- for (var i = 0, len = points.length; i < len; i++) {
- geoObjects[i] = new ymaps.Placemark(points[i], getPointData(i),
- getPointOptions());
- }
- clusterer.add(geoObjects);
- myMap.geoObjects.add(clusterer);
- myMap.setBounds(clusterer.getBounds(), {
- checkZoomRange: true
- });
- var groups = [
- { style: "islands#redIcon",
- items: [
- {
- center: [50.621523, 36.578564],
- name: "Корпус №1",
- Header: "Корпус №1",
- Body: "<p>Факультет математики и естественнонаучного образования;</p> <p>Институт инженерных технологий и естественных наук - инженерно-физическое направление;</p> <p><strong>Приемная комиссия</strong></p>",
- img: '<img src="image/logo_name.jpg" />'
- },
- {
- center: [50.621442, 36.577685],
- name: "Корпус №2",
- Header: "Корпус №2",
- Body:"Институт педагогический;<p> Факультет иностранных языков",
- img: '<img src="image/logo_name.jpg" />'
- },
Add Comment
Please, Sign In to add comment