Как сделать так, чтобы ballon в vue yandex map открывался при открытии компонента
Всем привет, я хочу сделать так, что бы balloon открывался сразу при открытии компонента, но у меня не получилось сделать и на данный момент он открывается только кликом на маркер.
<template>
<div class="default-modal map-modal">
<div class="default-modal__body map-modal__body">
<button class="btn map-modal__close" @click="$emit('close')">Закрыть</button>
<div class="map-modal__map">
<ClientOnly v-if="mapReady">
<yandex-map ref="map" :settings="settings" :coords="coords" zoom="14" :controls="['zoomControl']">
<ymap-marker :icon="icon" :coords="coords" :properties="properties" marker-id="123" />
</yandex-map>
</ClientOnly>
</div>
</div>
</div>
</template>
<script>
import { loadYmap, yandexMap, ymapMarker } from "vue-yandex-maps";
import ClientOnly from "vue-client-only";
export default {
name: "MapModal",
props: {
data: {
type: Object,
default: () => {},
},
},
data() {
return {
search: "",
mapReady: false,
debounceInterval: null,
coords: [42.89049523595949, 47.63682007602924],
marker: null,
map: null,
settings: {
apiKey: "",
lang: "ru_RU",
coordorder: "latlong",
version: "2.1",
},
icon: {
layout: "default#image",
imageHref: "/static/images/map-red-location.png",
imageSize: [40, 56],
imageOffset: [-18, -56],
balloonImageSize: [0, 0],
},
};
},
computed: {
properties() {
return {
balloonContentHeader: "Курьерский адрес",
balloonContentBody: this.data.address,
};
},
},
mounted() {
this.initMap();
this.debounceInterval = setInterval(() => {
window.addEventListener("resize", () => {
this.mapReady = false;
this.$nextTick(() => {
this.initMap();
});
});
}, 500);
},
methods: {
initMap() {
loadYmap(this.settings).then(() => {
window.ymaps.ready(() => {
window.ymaps.geocode(this.data.address).then((res) => {
this.coords = res.geoObjects.get(0).geometry.getCoordinates();
this.mapReady = true;
});
});
});
},
},
components: { yandexMap, ymapMarker, ClientOnly },
};
</script>
Источник: Stack Overflow на русском