JavaScript
1
Вклад в тег
ymaps.ready(init);
//Set default center and zoom
function init() {
myMap = new ymaps.Map('map_page', {
center: [45.0701, 38.9048],
zoom: 9
});
//Set user Icon
s = {
iconLayout: 'default#image',
iconImageHref: '/wp-content/themes/okhall/img/logo-map.svg',
iconImageSize: [87, 74],
iconImageOffset: [-43, -56]
};
//Set some points
m = {
m1: new ymaps.Placemark([45.0710, 38.9038], {}, s),
m1center: [45.0701, 38.9048],
m2: new ymaps.Placemark([45.0349, 39.1317], {}, s),
m2center: [45.0349, 39.1317],
m3: new ymaps.Placemark([44.7491, 37.7263], {}, s),
m3center: [44.7491, 37.7265],
m4: new ymaps.Placemark([45.2299, 38.1138], {}, s),
m4center: [45.2299, 38.1138],
m5: new ymaps.Placemark([45.8417, 40.1357], {}, s),
m5center: [45.8417, 40.1357],
m6: new ymaps.Placemark([44.9367, 37.9675], {}, s),
m6center: [44.9367, 37.9675]
};
//Disabled scroll
//myMap.behaviors.disable('scrollZoom');
//on mobile disable touch
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
//... отключаем перетаскивание карты
myMap.behaviors.disable('drag');
}
//Add points on the map
myMap.geoObjects
.add(m['m1'])
.add(m['m2'])
.add(m['m3'])
.add(m['m4'])
.add(m['m5'])
.add(m['m6']);
// ON RESIZE
//Get curent center and zoom
var pixelCenter = myMap.getGlobalPixelCenter('map_page');
console.log(pixelCenter);
//
function onResizeMap() {
if ($(window).width() > '992') {
//Set New center
myMap.setCenter([45.0701, 37.0048]);
var pixelCenter2 = myMap.getGlobalPixelCenter('map_page');
console.log(pixelCenter2);
} else {
myMap.setCenter([45.0701, 38.9048]);
}
} onResizeMap();
window.onresize = function () {
onResizeMap();
};
};