ymaps.ready(function () { var buildingCoordinates = [55.832659, 37.576118]; //Смещение карты, чтобы иконка была визуально по центру var offsetCoefficient = 0.001; var mapCenter = [ buildingCoordinates[0], buildingCoordinates[1] - offsetCoefficient ]; var myMap = new ymaps.Map('map', { center: mapCenter, zoom: 17, controls: [] }); // Отключаем все взаимодействия с картой myMap.behaviors.disable(['scrollZoom', 'drag', 'multiTouch', 'dblClickZoom']); var svgIcon = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; var iconSize; var iconOffset; if (window.innerWidth <= 768) { iconSize = [73, 88]; iconOffset = [-36, -87]; } else { iconSize = [146, 175]; iconOffset = [-73, -174]; } var myPlacemark = new ymaps.Placemark( buildingCoordinates, {hintContent: '', balloonContent: ''}, { iconLayout: 'default#imageWithContent', iconImageHref: 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svgIcon), iconImageSize: iconSize, iconImageOffset: iconOffset, hideIconOnBalloonOpen: false } ); myMap.panes.get('ground').getElement().style.filter = 'grayscale(100%)'; myMap.geoObjects.add(myPlacemark); var isMapInteractive = false; var mapElement = document.getElementById('map'); function activateMap(e) { if (!isMapInteractive) { myMap.behaviors.enable(['scrollZoom', 'drag', 'multiTouch', 'dblClickZoom']); isMapInteractive = true; setTimeout(function () { document.addEventListener('click', deactivateMap); document.addEventListener('touchend', deactivateMap); }, 100); e.stopPropagation(); } } function deactivateMap(e) { var target = e.target; if (e.type === 'touchend' || e.changedTouches || e.changedTouches[0]) { var touch = e.changedTouches[0]; target = document.elementFromPoint(touch.clientX, touch.clientY); } if (!mapElement.contains(target)) { myMap.behaviors.disable(['scrollZoom', 'drag', 'multiTouch', 'dblClickZoom']); isMapInteractive = false; document.removeEventListener('click', deactivateMap); document.removeEventListener('touchend', deactivateMap); } } mapElement.addEventListener('click', activateMap); mapElement.addEventListener('touchstart', activateMap); });