Is there a way to retrieve the component data using an external JavaScript function? I am looking to access markers, labels, and images.
Vue.component('home', {
template: '#home',
data: () => ({
markers: [],
label: '',
image: ''
}),
// Life-cycle methods
created() {
document.title = 'home';
ref.onSnapshot(snap => {
snap.docChanges().forEach(change => {
const { type, doc } = change;
if (type == 'added') {
addMarker(doc.id, doc.data()); // Call Method
}
});
});
}
});
// Function outside the Vue.component (within the same file)
function addMarker(id, data) {
let m = new gm.Marker({
map,
animation: gm.Animation.DROP,
position: data.position,
label: data.label,
image: data.image // Custom
});
markers.push(m); // Access Component Data - markers
m.addListener('click', e => {
label = m.label; // Access Component Data - label
image = m.image; // Access Component Data - image
info.open(map, m);
});
}