<div>
<div></div>
<div>I want to fill my map with user locations stored in firebase</div>
<div>a) get my user Id according to this scheme (attached):</div>
<div>with this code:</div>
<div>
function loadData() {
loading = true
console.debug("loading data")
// load the last X entries, ordered by timestamp property
firebaseDb.getValue("public/userlocations", {
}, function(success, key, value) {
if(success) {
uids=JSON.stringify(value)
console.log("uids", uids)
maps= JSON.parse(uids.valueOf())//property var maps:[]
}
loading = false
})
for (var i in maps) {
console.log("UIDssssssss",i )
getByUser(i) //function to obtain from the id of user
//the details of that particular user
}
}
b) Then a function to obtain from the id of user the details of that particular user:
function getByUser(uid){
firebaseDb.getValue("public/userlocations/"+ uid, {
limitToLast: maxListEntries,
orderByChild: "timestamp"
}, function(success, key, value) {
if(success) {
usuarios=JSON.stringify(value)
console.log("usua ", usuarios)
// mapview.model = usuarios.valueOf()
var parsedUser = JSON.parse(usuarios.valueOf())
var Location=parsedUser.Location
var email=parsedUser.email
var timestamp=parsedUser.timestamp
var userId=parsedUser.userId
var enlinea=parsedUser.enlinea
var latitude=parsedUser.latitude
var longitude=parsedUser.longitude
// dumpJSONObject(usuarios, 0 ); //here
console.log("array ", email)
//I filled the ListModel to then pass it to the MapItemView
model.append({Location: Location, email: email,timestamp:timestamp,userId:userId, enlinea:enlinea, latitud:latitud,longitud:longitud});
}
loading = false
})
}
But it does not work when loading it in the MapItemView, if this is my Firebase scheme:
{“a14ugxEJ8GMy2yziBwju9JfXG5x2”:{“Location”:”2° 55′ 49.5\” N, 75° 16′ 18.9\” W, 506.69m1532612560094″,”email”:”direstrepobr@gmail.com”,”enlinea”:true,”latitude”:2.9304237384376397,”longitude”:-75.27190396569229,”timestamp”:1532612560093,”userId”:”a14ugxEJ8GMy2yziBwju9JfXG5x2″},”tqJ1TRzCdwRxhrLjf205QhifJmY2″:{“Location”:”2° 55′ 52.4\” N, 75° 15′ 42.1\” W, 525.713m1532572733110″,”email”:”direstrepo@misena.edu.co”,”enlinea”:true,”latitude”:2.9312122240689873,”longitude”:-75.26168910793518,”timestamp”:1532572733108,”userId”:”tqJ1TRzCdwRxhrLjf205QhifJmY2″}}
usua {“Location”:”2° 55′ 49.5\” N, 75° 16′ 18.9\” W, 506.69m1532612560094″,”email”:”direstrepobr@gmail.com”,”enlinea”:true,”latitude”:2.9304237384376397,”longitude”:-75.27190396569229,”timestamp”:1532612560093,”userId”:”a14ugxEJ8GMy2yziBwju9JfXG5x2″}
</div>
Plase Helpme.
</div>
<div></div>
<div></div>