var left_sideSpace = $('.left_side').offset().top;
var left_sideHeight = $('.left_side').height();
var parentLeftSideHeight = $('.content').height();
console.log('left_sideHeight', left_sideHeight, 'left_side', left_sideSpace, 'parentLeftSideHeight', parentLeftSideHeight);
позиция top
Например позиция top + высота блока = высоте родительскому то делать блок прижатым к низу
getBaloonsOnMap() {
var coords = [];
queryParametrs.left_top_lat = this.myMap.getBounds()[1][0];
queryParametrs.left_top_long = this.myMap.getBounds()[0][1];
queryParametrs.right_bot_lat = this.myMap.getBounds()[0][0];
queryParametrs.right_bot_long = this.myMap.getBounds()[1][1];
queryParametrs.town_id = JSON.parse(localStorage.getItem('town')).id;
callApi('shop_map', queryParametrs, '').then((res) => {
var myShop = res.data.data;
for (var j = 0, max = myShop.length; j < max; j ++) {
coords.push([ myShop[j].lat, myShop[j].long, myShop[j].name ])
}
var obj = {
type: 'FeatureCollection',
features: coords.map(function(p){
return {
type: 'Feature',
properties: {
balloonContent: p[2]
},
geometry: {
type: 'Point',
coordinates: [p[0], p[1]]
}
}
})
};
var objects = ymaps.geoQuery(obj);
objects.searchInside(this.myMap).addToMap(this.myMap);
this.myMap.events.add('boundschange', function () {
var visibleObjects = objects.searchInside(this.myMap).addToMap(this.myMap);
objects.remove(visibleObjects).removeFromMap(this.myMap);
});
});
},
ymaps.ready(() => {
console.log('this', this);
this.myMap = new ymaps.Map("map", {
center: this.getCenterCoord(),
zoom: 15,
});
this.myMap.events.add('actionbegin', this.getBaloonsOnMap());
this.myMap.events.add('boundschange', function (e) {
if (e.get('newCenter') != e.get('oldCenter')) {
this.getBaloonsOnMap();
}
});
})
Uncaught TypeError: Cannot read property 'getBaloonsOnMap' of null
То есть, вы вызвали метод mapShops, карта создалась, а потом, когда вы пытаетесь её отцентрировать - вместо объекта карты в myMap лежит null
ymaps.ready(() => {
console.log('this', this);
this.myMap = new ymaps.Map("map", {
center: this.getCenterCoord(),
zoom: 15,
});
})
ymaps.ready(() => {
this.myMap = new ymaps.Map("map", {
center: this.getCenterCoord(),
zoom: 15,
});
})
setMapCenter() {
if (this.myMap) {
this.myMap.setCenter(this.getCenterCoord());
}
}
Этот код я использую, в responsive axios запроса