I want to display these values on markers from the fcmUsers list
when user click on marker it will show its own value or data in text view from the fcmUsers list
fcmUsers List have public Long createdat; and public Long hajjappnum;
DatabaseReference UserRef = FirebaseDatabase.getInstance().getReference().child("GPSLocationHistory").child("DevicesLatest");
UserRef.keepSynced(true);
new GetDataFromFirebase().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
FirebaseDatabase database = FirebaseDatabase.getInstance();
// myRef = database.getReference("GPSLocationHistory/DevicesLatest");
UserRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
latLngList.clear();
mMap.clear();
if (marker != null) {
marker.remove();
}
Toast.makeText(MapsActivity.this, "change", Toast.LENGTH_SHORT).show();
Iterator<DataSnapshot> dataSnapshots = dataSnapshot.getChildren().iterator();
fcmUsers = new ArrayList<>();
i = 0;
while (dataSnapshots.hasNext()) {
DataSnapshot dataSnapshotChild = dataSnapshots.next();
ModelClassFireBase fcmUser = dataSnapshotChild.getValue(ModelClassFireBase.class);
fcmUsers.add(fcmUser);
LatLng latLng = new LatLng(Double.parseDouble(fcmUsers.get(i).lati.toString()), Double.parseDouble(fcmUsers.get(i).longi.toString())); // Use your server's methods
latLngList.add(latLng);
mark1 = mMap.addMarker(new MarkerOptions().title(fcmUsers.get(i).Battery.toString()).position(latLngList.get(i)));//.icon(BitmapDescriptorFactory.fromResource(R.drawable.female4)));
// Toast.makeText(getApplicationContext(), uniqueids.get(i).toString(), Toast.LENGTH_LONG).show();
markerList.add(mark1);
i++;
if (fcmUsers.size() > 0) {
} else {
// Display dialog for there is no user available.
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// for handling database error
}
});
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
// Getting view from the layout file info_window_layout
View v = getLayoutInflater().inflate(R.layout.info_widow_layout, null);
// Getting the position from the marker
LatLng latLng = arg0.getPosition();
// Getting reference to the TextView to set latitude
TextView userbattery = (TextView) v.findViewById(R.id.tv_lat);
// Getting reference to the TextView to set longitude
// TextView tvLng = (TextView) v.findViewById(R.id.tv_lng);
// ImageView userimage = (ImageView) v.findViewById(R.id.userimage);
userbattery.setText("user battery:" + fcmUsers.get(i-1).Battery.toString());
return v;
}
});