Сайт Fakel Gym
https://fakelgym.cp.good-production.xyz/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.5 KiB
74 lines
2.5 KiB
ymaps.ready(function () {
|
|
|
|
var buildingCoordinates = [56.462317, 84.969289];
|
|
|
|
// Смещение карты, чтобы иконка была визуально по центру
|
|
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 myPlacemark = new ymaps.Placemark(
|
|
buildingCoordinates,
|
|
{hintContent: '', balloonContent: ''},
|
|
{
|
|
preset: 'islands#greyIcon'
|
|
}
|
|
);
|
|
|
|
// Делаем карту черно-белой
|
|
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);
|
|
}); |