I need help accessing data in firebase firestore snapshot, I need latitude and longitude. I have both fields in database as well as Geopoint. I can see the data in console.log, but I can't access individual values. So far I tried different ways, here, with doc.latitude or doc.longitude I don't get errors but can't retrieve the data neither.
function initialize() {
var latlng = new google.maps.LatLng(18.465733327729314, -69.93029399778331);
var myOptions = {disableDefaultUI: true, zoom: 9, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("map"), myOptions);
db = firebase.firestore();
db.collection("GranSantoDomingo").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, "=>", doc.data());
var marker = new google.maps.Marker({
position: {lat: parseFloat(doc.latitude), lng: parseFloat(doc.longitude)},
map: map,
});
}
);
});
}
The system doesn't let me post an image, but the data structure is like this:
{
"location":"Geopoint(18.7611489,-69.0386113)",
"sector":"EL SEIBO I ",
"calle":"Av. MANUELA DIEZ ( EN LA GERENCIA)",
"latitude":"18.7611489",
"longitude":"-69.0386113"
}