var modalMap = false; var modalPl = false; function drawModalPlacemark(coords,title) { if(modalPl) modalMap.geoObjects.remove(modalPl); modalPl = new ymaps.Placemark(coords, { hintContent: title }, { iconLayout: 'default#image', iconImageHref: '/imgs/placemark.png', iconImageSize: [34, 40], iconImageOffset: [-17, -40] }); modalMap.geoObjects.add(modalPl); modalMap.panTo(modalPl.geometry.getCoordinates(), {checkZoomRange: true}); } function drawModalMap(coords,title) { ymaps.ready( function() { modalMap = new ymaps.Map('modal_map', { center: [55.733835, 37.588227], zoom: 10, controls: ['zoomControl', 'typeSelector', 'geolocationControl'] }); drawModalPlacemark(coords,title); }); } function showModalMap(coords,title,url,loc) { $('#modal_map_h2').html(title); $('#modal_map_h2').attr('href', url); $('#modal_map_loc').html(loc); mc_map.showModal(); if(modalMap) drawModalPlacemark(coords,title); else $.getScript('//api-maps.yandex.ru/2.1.3/?load=package.full&apikey=ed357e36-5b25-48d0-af72-c339c814a6a2&lang=ru-RU', function() { drawModalMap(coords,title); }); } $(function() { if(typeof page_loaded == 'function') page_loaded(); });