Loading map pins from firebase onto mapkit in swift for all users to be able to see

Viewed 636

Im creating a tagging app, where a user can tag street art to a map, this information is then available for all users to see.

I can upload my data to Firebase however Im struggling being able to pull this data back down to appear on the map as an annotation.

Firebase Data Structure

I have created a loadCustomAnnotations() to load up the database information as a pin on my map, I know I need to observe the values and just load in the "art" path, and loop over all the results however I cant seem to turn this into an annotation! can anyone help?! thanks.

func loadCustomLocations() {

    FIRDatabase.database().reference(withPath: "art")

    let artPin = FIRDatabase.database().reference(withPath: "art")

    artPin.observe(.value, with: { snapshot in


        for item in snapshot.children {
            guard let snapshot = item as? FIRDataSnapshot else { continue }

            let ref = art(snapshot: snapshot)

            print(snapshot)

            self.artDrops.append(ref)

     //       self.makeAnnotation(artDrops: art)


        }
    })
}

}

this function now prints all my locations i just need to know how to turn this into an annotation!

Printing Locations

1 Answers
Related