this.myMap.events.add('boundschange', (e) => {
setMapCenter() {
if (this.myMap) {
this.myMap.setCenter(this.getCenterCoord());
}
}
methods: {
getCenterCoord() {
var town = JSON.parse(localStorage.getItem('town'));
return [ town.lat, town.lng ];
},
setMapCenter() {
this.myMap.setCenter(this.getCenterCoord());
}
...mapShops() {
ymaps.ready(() => {
this.myMap = new ymaps.Map("map", {
center: this.getCenterCoord(),
zoom: 15,
});
})
}updated() {
this.setMapCenter();
}
Хотите ещё один экземпляр - ну так добавьте столько, сколько вам надо. Только конечно, не в index.html - его трогать не надо. Делать npm run build каждый раз не надо - сделаете, когда всё готово будет. А до того - npm run dev.