Advertisement
Guest User

Untitled

a guest
Jul 8th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         // Добавление всех меток на карту
  2.         $.each(mapController.deviceData, function(index, item) {
  3.                     var placemark = new ymaps.Placemark([item.lat, item.lon], {
  4.                         balloonContent: 'Загрузка...',
  5.                         id: item.id
  6.                     }, {
  7.                         preset: mapController.getPlacemarkPreset(item.type)
  8.                     });
  9.  
  10.                     mapController.clusterer.add(placemark);
  11.                     placemark.events.add('click', mapController.placemarkClick);
  12.                 });
  13.  
  14.         // Клик по конкретной метке
  15.     placemarkClick: function(event) {
  16.                 var placemark = event.get('target'),
  17.                     id        = placemark.properties.get('id');
  18.  
  19.                 $.eAjax({
  20.                     url: '/api/devices/info',
  21.                     data: {
  22.                         id: id
  23.                     },
  24.  
  25.                     success: function(response) {
  26.                         if (response.success) {
  27.                             var footerSource = $('#balloonFooterTemplate').html(),
  28.                                 template     = Handlebars.compile(footerSource),
  29.                                 html         = template({
  30.                                     id: id,
  31.                                     name: response.data.name
  32.                                 });
  33.  
  34.                             placemark.properties.set('balloonContentFooter', html);
  35.                         } else {
  36.                             $.ejGrowl('error', 'Ошибка');
  37.                         }
  38.                     }
  39.                 });
  40.             },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement