#javascript #vue.js
#javascript #vue.js
Вопрос:
## Mounted function ##
Мне удается отобразить мои маркеры, но мне трудно добавить событие щелчка
к каждому маркеру.
async mounted() {
try {
const googlenter code heree = await gmapsInit();
const geocoder = new google.maps.Geocoder();
const map = new google.maps.Map(this.$el);
enter code here
geocoder.geocode({ address: "Salt Lake City" }, (results, status) => {
if (status !== "OK" || !results[0]) {
throw new Error(status);
}
map.setCenter(results[0].geometry.location);
map.fitBounds(results[0].geometry.viewport);
});
const markers = this.allListings.map(marker => {
new google.maps.Marker({
...marker,
map,
title: marker.businessName
});
Именно здесь я хочу добавить событие щелчка
marker.addListener("click", toggleBounce);
});
} catch (error) {
console.error(error);
}
},
};
</script>