Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to make an online update of the marker from the database?

 DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference ref = rootRef.child("markers").child("m-1");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
    for (DataSnapshot child : dataSnapshot.getChildren()) {
                double lat = child.child("latit").getValue(Double.class);
                double lon = child.child("longit").getValue(Double.class);
                Log.d(TAG, lat + ", " + lon);
                LatLng almaty = new LatLng(lat, lon);
                mMap.addMarker(new MarkerOptions().position(almaty).title("Marker in Almaty"));
            }
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
    Log.d(TAG, databaseError.getMessage()); //Don't ignore errors!
}
 };
ref.addListenerForSingleValueEvent(valueEventListener);

How to make an online update of the marker from the firebase realtime database. My option does not work. I am trying to make a update of the marker in real time. The marker takes coordinates from the database

Comments