GeoFire Step-by-Step Tutorial Android

7,744 views
Skip to first unread message

Reuben Cabrera

unread,
Oct 5, 2016, 10:45:47 AM10/5/16
to Firebase Google Group
I cannot find any tutorials regarding how to use Geofire in Android. is there any other tutorial for this? 
it seems that https://github.com/firebase/geofire-java is not updated?

what I want to accomplish is.

Assumptions: user is logged in.

1. user can see his current location and updates the DB
2. When user presses "search nearby people", user is able to view online users within a 2km radius.

any help or any sample code will be appreciated thank you :)

Jacob Wenger

unread,
Oct 5, 2016, 4:48:33 PM10/5/16
to fireba...@googlegroups.com
Hey Reuben,

What about that repo is not updated? I believe the README should be completely up-to-date. You can find the full API reference here.

1. user can see his current location and updates the DB

You would need to use the Android API for getting a user's location and then you can add that to the GeoFire index via setLocation().

2. When user presses "search nearby people", user is able to view online users within a 2km radius.

You'd use a GeoQuery to do this. Check the API reference for it's API.

Any sample code will be appreciated

Check out the FSVehicles example here.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/fb68660b-6729-4c7d-b9cc-de096992644b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reuben Cabrera

unread,
Oct 11, 2016, 9:37:00 AM10/11/16
to Firebase Google Group
Do I need to store my Location to my Database?

Jacob Wenger

unread,
Oct 11, 2016, 1:02:29 PM10/11/16
to fireba...@googlegroups.com
If you just want to query locations close to your current location, just create a GeoQuery and you don't need to store your location. If you want others to query on your location, then yes, you'll need to store that in your GeoFire index.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Reuben Cabrera

unread,
Oct 17, 2016, 10:49:37 AM10/17/16
to Firebase Google Group
I tried the SFVehicles, where does the nearby location data come from? does it come from the DB?


On Wednesday, October 5, 2016 at 10:45:47 PM UTC+8, Reuben Cabrera wrote:

Reuben Cabrera

unread,
Oct 19, 2016, 10:17:19 AM10/19/16
to Firebase Google Group
i dont understand how it puts multiple markers using the hashmap. 

@Override
public void onKeyEntered(String key, GeoLocation location) {
// Add a new marker to the map
Marker marker = this.map.addMarker(new MarkerOptions().position(new LatLng(location.latitude, location.longitude)));
this.markers.put(key, marker);
}
 
I was kinda expecting a loop to see all within tthe given radius

On Wednesday, October 5, 2016 at 10:45:47 PM UTC+8, Reuben Cabrera wrote:

Jacob Wenger

unread,
Oct 25, 2016, 5:53:02 PM10/25/16
to fireba...@googlegroups.com
The onKeyEntered() callback is fired for every key in your GeoFire index which matches your GeoQuery. The GeoFire library itself will call that method when appropriate. All you need to do is respond to the event.

Hope that helps,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Reuben Cabrera

unread,
Oct 26, 2016, 10:45:20 AM10/26/16
to Firebase Google Group
I see. so I manage to finally get some markers setup so what I want to do next when I click on that marker I can send him/her a message. is that possible through Firebase cloud messaging? or with the use of notifications?


On Wednesday, October 26, 2016 at 5:53:02 AM UTC+8, Jacob Wenger wrote:
The onKeyEntered() callback is fired for every key in your GeoFire index which matches your GeoQuery. The GeoFire library itself will call that method when appropriate. All you need to do is respond to the event.

Hope that helps,
Jacob
On Wed, Oct 19, 2016 at 2:50 AM, Reuben Cabrera <reubenb...@gmail.com> wrote:
i dont understand how it puts multiple markers using the hashmap. 

@Override
public void onKeyEntered(String key, GeoLocation location) {
// Add a new marker to the map
Marker marker = this.map.addMarker(new MarkerOptions().position(new LatLng(location.latitude, location.longitude)));
this.markers.put(key, marker);
}
 
I was kinda expecting a loop to see all within tthe given radius

On Wednesday, October 5, 2016 at 10:45:47 PM UTC+8, Reuben Cabrera wrote:
I cannot find any tutorials regarding how to use Geofire in Android. is there any other tutorial for this? 
it seems that https://github.com/firebase/geofire-java is not updated?

what I want to accomplish is.

Assumptions: user is logged in.

1. user can see his current location and updates the DB
2. When user presses "search nearby people", user is able to view online users within a 2km radius.

any help or any sample code will be appreciated thank you :)

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Jacob Wenger

unread,
Oct 26, 2016, 1:50:06 PM10/26/16
to fireba...@googlegroups.com
If you just want messages in the sense of a chat, you can make use of the Realtime Database. If you want messages in the sense of push messages, you can't actually send push messages directly via the web SDK. But you can set up your own messaging server and receive push messages on the web as documented here.

Cheers,
Jacob

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Reuben Cabrera

unread,
Nov 1, 2016, 4:47:41 PM11/1/16
to Firebase Google Group
for example, I want to send a message to a specific user, can I use his/her corresponding userID to send him/her a message or a notification? correct me if im wrong but that is not how push notifications work

Jacob Wenger

unread,
Nov 2, 2016, 2:08:25 PM11/2/16
to fireba...@googlegroups.com
Hey Reuben,

I would suggest using the Firebase Realtime Database for this task, not Firebase Messaging.

Cheers,
Jacob

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages