As a newcomer to Typescript, I am struggling to understand how to access the variables latitude1 and latitude2 outside of the this.ref.on('value', (snapshot) function in order to add their values to the locations array. Can anyone provide some guidance on this? Thank you in advance!
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.ref.on('value', (snapshot) => {
//console.log(firebaseToArray(snapshot)[0].latitude);
var latitude1 = firebaseToArray(snapshot)[0].latitude;
var latitude2 = firebaseToArray(snapshot)[1].latitude;
});
var locations = [
['3/4', latitude1, 2.1743558],
['1/6', latitude2, 2.1843558]
];