Skip to content
Advertisement

Displaying data from Firebase into custom Info Window

I’m trying to display a couple of user details from Firebase into a custom Map Marker after the location data has been retrieved from the database but I don’t know if I should implement FirebaseRecyclerAdapter or a normal one. How should I do this?

I’m trying to at least retrieve the user’s name, emergency type, and alert level and display on the Info Window when the marker is clicked:

JavaScript

Here is my onMapReady():

JavaScript

My adapter:

JavaScript

Advertisement

Answer

According to your last comment:

In the Users node, the Name, Emergency Type, and Alert Level

To be able to get the values of the indicated fields that correspond to a specific user and add them to a Google Map, please use the following lines of code:

JavaScript

The result of the following code will be the addition of a marker that corresponds to the user location on the Google Map. The title of the marker will contain, the name, the emergency type, and the alert level.

This will indeed work for a single user, if you need to show all users, then simply loop through the DataSnapshot object using getChildren() method like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement