B4A Library GeoFire - Store and request Locations in a Firebase Realtime Database

This is a wrap for this Github project.


Setup:
1. Integrate Firebase.
Add Google Play Snipped and Firebase Snippet.
2. Setup Rules for the GeoFire-Part in your Realtimedatabase.

Here are some Examples:

A) Authenticated

B) No deletes

C) No Updates

D) Allow anyone

Sample code

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private gf As GeoFire
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    gf.Initialize("GeoFire","geoFire") ' geoFire is the "folder" in your Databaseroot... It can be any subfolder/reference. Make sure the rules mathes the right reference.
    'gf.setLocation("HQ-Mannes",50.7907, 6.4659)
    gf.getLocation("HQ-Mannes")
 
    gf.queryAtLocation(50.7907, 6.4659,50)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub GeoFire_onCancelled(key As String)
    Log($"GeoFire_onCancelled(${key})"$)
End Sub
Sub GeoFire_onGeoQueryError(error As String)
    Log($"GeoFire_onGeoQueryError(${error})"$)
End Sub
Sub GeoFire_onGeoQueryReady()
    Log($"GeoFire_onGeoQueryReady()"$)
End Sub
Sub GeoFire_onKeyEntered(key As String, lat As Double, lon As Double)
    Log($"GeoFire_onKeyEntered(${key}, ${lat}, ${lon})"$)
End Sub
Sub GeoFire_onKeyExited(key As String)
    Log($"GeoFire_onKeyExited(${key})"$)
End Sub
Sub GeoFire_onKeyMoved(key As String, lat As Double, lon As Double)
    Log($"GeoFire_onKeyMoved(${key}, ${lat}, ${lon})"$)
End Sub
Sub GeoFire_onLocation(key As String, lat As Double, lon As Double)
    Log($"GeoFire_onLocation(${key}, ${lat}, ${lon})"$)
End Sub
Sub GeoFire_onLocationSet(key As String, error As String)
    Log($"GeoFire_onLocationSet(${key},${error})"$)
End Sub

Based on the code here you can see this Content in your Database



In this case i´m using this rules
 

Attachments

  • FirebaseGeoV1.0.zip
    31.3 KB · Views: 477
Last edited:

javiers

Active Member
Licensed User
Longtime User
Congratulations for your work.
How can I delete a record?
A greeting
 

ocalle

Active Member
Licensed User
Longtime User
hello, one quiz, with this library is possible send a message chat?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…