I have these nodes, each of these nodes contains data, They are structured in this way
In the "MainActivity" I have a map, on the map there are three markers
Each one of these markers contains data which are so
I rescue the data from Firebase in this way:
FirebaseUtils.getPostRef().orderByKey().addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(final DataSnapshot dataSnapshot, String s) {
// posicion
latitud = dataSnapshot.getValue(Post.class).getLatitud();
longitud = dataSnapshot.getValue(Post.class).getLongitud();
// datos
titulo = dataSnapshot.getValue(Post.class).getTitulo();
costo = dataSnapshot.getValue(Post.class).getCosto();
mes = dataSnapshot.getValue(Post.class).getMes();
numeroDia = dataSnapshot.getValue(Post.class).getDia();
organizadoPor = dataSnapshot.getValue(Post.class).getOrganizadoPor();
descripcion = dataSnapshot.getValue(Post.class).getDescripicion();
hora = dataSnapshot.getValue(Post.class).getHora();
minutos = dataSnapshot.getValue(Post.class).getMinutos();
id = dataSnapshot.getValue(Post.class).getId();
final ArrayList<Post> pp = new ArrayList<Post>();
// marker
BitmapDescriptor bm = BitmapDescriptorFactory.fromResource(R.mipmap.m5);
LatLng latLng1 = new LatLng(latitud, longitud);
mMarker = new MarkerOptions().position(latLng1).title(titulo).snippet(costo).icon(bm);
mp.add(mMap.addMarker(mMarker));
mPost.setTitulo(titulo);
final Marker mk656 = mMap.addMarker(new MarkerOptions().position(latLng1).title(titulo).snippet(costo).icon(bm));
mk656.setTag(mPost);
mp.add(mk656);
}
All that method puts markers on the map, Now the problem is:
By clicking on a marker I need that specific data For example marker 1 has Title "HELLO"
I need to click on that information "HELLO" is rescued with another activity
Try this with my model class Post mPost = new Post (); Intent intent = new Intent (MainAcivity.this, AnotherActicity.class); intent.putExtra ("post", mPost); startActivity (intent);
and this in the other activity:
Intent intentI = getIntent();
mPost = (Post) intentI.getSerializableExtra("post");
initPantallaPrincipal();
The data is received successfully, but the data of the last added marker is received for example:
I add a marker A with Title A
and I click on the B marker with title B
in the "AnotherActivity" where I rescue the data I get the data of the marker A bone the last addition and I need the data of the specific marker