Guest User

Untitled

a guest
May 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. var places = [];
  2. groups.forEach(function (grp) {
  3. grp.items.forEach(function (plc) {
  4. places.push(plc)
  5. });
  6. });
  7. // Создаем собственный макет с информацией о выбранном геообъекте.
  8. var customItemContentLayout = ymaps.templateLayoutFactory.createClass(
  9. // Флаг "raw" означает, что данные вставляют "как есть" без экранирования html.
  10. '<h2 class=ballon_header>{{ properties.balloonContentHeader|raw }}</h2>' +
  11. '<img class=balloon_img>{{properties.balloonImage|raw }}</img>'+
  12. '<div class=ballon_body>{{ properties.balloonContentBody|raw }}</div>' +
  13. '<div class=ballon_footer>{{ properties.balloonContentFooter|raw }}</div>'
  14. );
  15.  
  16. var clusterer = new ymaps.Clusterer({
  17. clusterDisableClickZoom: true,
  18. clusterOpenBalloonOnClick: true,
  19. // Устанавливаем режим открытия балуна.
  20. // В данном примере балун никогда не будет открываться в режиме панели.
  21. clusterBalloonPanelMaxMapArea: 0,
  22. // Устанавливаем размер макета контента балуна (в пикселях).
  23. clusterBalloonContentLayoutWidth: 500,
  24. // Устанавливаем собственный макет.
  25. clusterBalloonItemContentLayout: customItemContentLayout,
  26. // Устанавливаем ширину левой колонки, в которой располагается список всех геообъектов кластера.
  27. clusterBalloonLeftColumnWidth: 120
  28. });
  29.  
  30. // Заполняем кластер геообъектами со случайными позициями.
  31. getPointData = function (index) {
  32. return {
  33. balloonImage: places[index].img,
  34. balloonContentHeader: places[index].name,
  35. balloonContentBody: places[index].Body,
  36. balloonContentFooter: places[index].Footer,
  37. clusterCaption: '<strong>' + places[index].name + '</strong>'
  38. };
  39. },
  40. getPointOptions = function () {
  41. return {
  42. preset: 'islands#redIcon'
  43. };
  44. },
  45. points = [];
  46. groups.forEach(function (grp) {
  47. grp.items.forEach(function (plc) {
  48. points.push(
  49. plc.center
  50. );
  51. });
  52. });
  53. geoObjects = [];
  54.  
  55. for (var i = 0, len = points.length; i < len; i++) {
  56. geoObjects[i] = new ymaps.Placemark(points[i], getPointData(i),
  57. getPointOptions());
  58. }
  59. clusterer.add(geoObjects);
  60. myMap.geoObjects.add(clusterer);
  61.  
  62. myMap.setBounds(clusterer.getBounds(), {
  63. checkZoomRange: true
  64. });
  65.  
  66. var groups = [
  67. { style: "islands#redIcon",
  68. items: [
  69. {
  70. center: [50.621523, 36.578564],
  71. name: "Корпус №1",
  72. Header: "Корпус №1",
  73. Body: "<p>Факультет математики и естественнонаучного образования;</p> <p>Институт инженерных технологий и естественных наук - инженерно-физическое направление;</p> <p><strong>Приемная комиссия</strong></p>",
  74. img: '<img src="image/logo_name.jpg" />'
  75. },
  76. {
  77. center: [50.621442, 36.577685],
  78. name: "Корпус №2",
  79. Header: "Корпус №2",
  80. Body:"Институт педагогический;<p> Факультет иностранных языков",
  81. img: '<img src="image/logo_name.jpg" />'
  82. },
Add Comment
Please, Sign In to add comment