Open zoro238 opened 5 years ago
Hey,
So basically geofire doesnt have save capability, thats provided by firebase itself. What you'll need to do (for now at least) is save the document as normal, and in the oncomplete use:
geoFire.setLocation(YOUR_ID, YOUR_LATITUDE, YOUR_LONGITUDE, this);
You'll need the class youre calling setLocation from to implement SetLocationListener. In the onCompleted method you'll either get null if the location was set successfully, or an exception if not.
ok i am test then replay
this error
![Uploading 12.JPG…]()
Hi,
Please check the docs. You need to give GeoFire your collection reference rather than your database
private CollectionReference myCollection = db.collection("myCollection");
private GeoFire geoFire = new GeoFire(myCollection);
now ok , but record one value where lat,lon g
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference myCollection = db.collection("myCollection");
GeoFire geoFire= new GeoFire(myCollection);
geoFire.setLocation("hi", mlocation.getLatitude(), mlocation.getLongitude(),this);
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference myCollection = db.collection("myCollection");
GeoFire geoFire= new GeoFire(myCollection);
geoFire.setLocation("hi", mlocation.getLatitude(), mlocation.getLongitude(),this);
Hi,
I've just updated the docs in the readme. Please check those. You'll need to use standard Firestore utilities to store your document first. GeoFire only updates the geoFireLocation field. The google docs are good for explaining how to use Firestore to store documents.
https://firebase.google.com/docs/firestore/quickstart
You'll need to store your document, and then in the onComplete, use geoFire.setLocation() to update the document with the id reference you get back and the latitude and longitude values.
I'm going to close this issue, as I believe you should now have all the information you need.
To summarise:
In your examples, geoFire.setLocation needs to go in the onSuccess listener for your user addition. In there, use the ID from the returned document reference, and your latitude and longitude from the user object. Then you will have your latitude and longitude, and the necessary geoFireLocation.
Inside the method appears a line but outside without a line ..
Hi. You are not implementing the listener. As the message tells you, you need to implement SetLocationListener.
Thanks, Martin
How to implement SetLocationListener.
i implement public class Find extends AppCompatActivity implements MyTracker.ADLocationListener , SetLocationListener {
and add
@Override
public void onCompleted(Exception exception) {
Log.w(TAG, "onCompleted ", exception);
}
and same error >>
Okay, let me have a look. If you've implemented everything correctly then it seems there could be an issue. Leave it with me and I'll have a look ASAP.
ok and thank you alots
How do I put my data in it (set loaction ? and view error
this CollectionReference is database ref