javascript - Read data from Firebase and put into an array -
i'm building ionic application native google maps , firebase. want load multiple markers on map, , positions of these markers (latitude , longitude) in firebase structure:

so created provider , function getpins() these positions:
import { ... }; @injectable() public arredoresref:firebase.database.reference; export class arredoresprovider { constructor() { this.arredoresref = firebase.database().ref('/local') } getpins(): firebase.database.reference { return this.arredoresref.child('/local'); } } and i'm trying put these positions in array:
import { ... }; @ionicpage({ ... }) @component({ ... }) export class arredorespage { constructor( ... ) { ... } ionviewdidenter() { this.arredoresprovider.getpins().on('value', snapshot => { this.pins = []; snapshot.foreach( snap => { this.pins.push({ latitude: snap.val().latitudelocal, longitude: snap.val().longitudelocal }); return false }); }); } } but it's not working! it's first time working firebase , ionic, i'm confused how firebase read data.
this text useful me, not use firebase data.
finally, apologize bad english!
i have implemented first solution this: get data firebase in ionic 2
essentially, have use list reference , make sure call using options {enablesnapshot: true}. moreover, data in structure not have .latitudelocal property on it. instead, have go further in data structure access these, example, use .foreach statement.
Comments
Post a Comment