Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Добавление всех меток на карту
- $.each(mapController.deviceData, function(index, item) {
- var placemark = new ymaps.Placemark([item.lat, item.lon], {
- balloonContent: 'Загрузка...',
- id: item.id
- }, {
- preset: mapController.getPlacemarkPreset(item.type)
- });
- mapController.clusterer.add(placemark);
- placemark.events.add('click', mapController.placemarkClick);
- });
- // Клик по конкретной метке
- placemarkClick: function(event) {
- var placemark = event.get('target'),
- id = placemark.properties.get('id');
- $.eAjax({
- url: '/api/devices/info',
- data: {
- id: id
- },
- success: function(response) {
- if (response.success) {
- var footerSource = $('#balloonFooterTemplate').html(),
- template = Handlebars.compile(footerSource),
- html = template({
- id: id,
- name: response.data.name
- });
- placemark.properties.set('balloonContentFooter', html);
- } else {
- $.ejGrowl('error', 'Ошибка');
- }
- }
- });
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement