Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.addEventListener('DOMContentLoaded', function () {
  2.     if (coords.length > 0) {
  3.         ymaps.ready(function () {
  4.             var myMap = new ymaps.Map("map", {
  5.                 center: [64.542984, 40.537155],
  6.                 zoom: 12
  7.             });
  8.  
  9.  
  10.             var myGeoObjects = [];
  11.             for (var i = 0; i<coords.length; i++) {
  12.                 myGeoObjects[i] = new ymaps.GeoObject({
  13.                     geometry: {
  14.                         type: "Point",
  15.                         coordinates: coords[i].coords
  16.                     },
  17.  
  18.                     properties: {
  19.                         hintContent: coords[i].hint,
  20.                         balloonContentHeader: coords[i].contentHeader,
  21.                     }
  22.  
  23.  
  24.                 }, {
  25.                     // Опции.
  26.                     // Иконка метки будет растягиваться под размер ее содержимого.
  27.                     preset: coords[i].type,
  28.                     // Метку можно перемещать.
  29.                     draggable: true
  30.                 });
  31.                
  32.             }
  33.            
  34.  
  35.             var myClusterer = new ymaps.Clusterer();
  36.             myClusterer.add(myGeoObjects);
  37.             myMap.geoObjects.add(myClusterer);
  38.         });
  39.     }
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement