I'm just learning and I'm doing an app in android studio where a map with different markers should come out, and each one should display an infowindow with different information (text and image) .. but for some error of mine only shows me the last infowindow configured repeated in all the markers that I add, it is as if over writing the info. the markers I have added them in the following way in the CajerosCer class ..
Marker marker1 = mMap.addMarker(new MarkerOptions().position(new LatLng(-33.42218, -70.6105))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitrojo1)));
Cajero c1 = new Cajero("Banco 1", "Activo", "", "direccion 1", "9:00 a 23:00", R.drawable.debitrojo1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c1));
Marker marker2 = mMap.addMarker(new MarkerOptions().position(new LatLng(-33.415316, -70.540559))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c2 = new Cajero("Banco 2", "Inactivo", "", "direccion 2", "9:00 a 23:00", R.drawable.debitverde1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c2));
Marker marker3 = mMap.addMarker(new MarkerOptions().position(new LatLng(-33.431447, -70.609332))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c3 = new Cajero("Banco 3", "Inactivo", "", "direccion 3", "9:00 a 23:00", R.drawable.verde1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c3));
Marker marker4 = mMap.addMarker(new MarkerOptions().position(new LatLng(-40.573886, -73.136952))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c4 = new Cajero("Banco 4", "Activo", "", "direccion 4", "9:00 a 23:00", R.drawable.verde1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c4));
Marker marker5 = mMap.addMarker(new MarkerOptions().position(new LatLng(-40.574308, -73.15902))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c5 = new Cajero("Banco 5", "Activo", "", "direccion 5","9:00 a 23:00", R.drawable.verde1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c5));
Marker marker6 = mMap.addMarker(new MarkerOptions().position(new LatLng(-40.578722, -73.174982))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c6 = new Cajero("Sucursal 6", "INACTIVO", "SIN INFORMACION", "direccion 6", "9:00 a 14:00", drawable.rojo1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c6));
Marker marker7 = mMap.addMarker(new MarkerOptions().position(new LatLng(-40.578722, -74.174982))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.debitverde1)));
Cajero c7 = new Cajero("Sucursal 7", "ACTIVO", "SIN INFORMACION", "direccion 7", "9:00 a 14:00", drawable.rojo1);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(LayoutInflater.from(this), c7));
}
I also have the CustomInfoWindowAdapter class class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
private static final String TAG = "CustomInfoWindowAdapter";
private LayoutInflater inflater;
private Cajero c;
public CustomInfoWindowAdapter(LayoutInflater inflater, Cajero c){
this.inflater = inflater;
this.c = c;
}
@Override
public View getInfoWindow(final Marker marker) {
View infoWindows = inflater.inflate(R.layout.activity_custom_info_window_adapter, null);
ImageView img = (ImageView) infoWindows.findViewById(R.id.info_window_imagen1);
img.setImageResource(c.getLayout());
((TextView) infoWindows.findViewById(R.id.info_window_nombre)).setText("Cajero " + c.getNombre());
((TextView) infoWindows.findViewById(R.id.info_window_estado)).setText("Estado: " + c.getEstado());
((TextView) infoWindows.findViewById(R.id.info_window_saldo)).setText("Saldo: " + c.getSaldo());
((TextView) infoWindows.findViewById(R.id.info_window_ubicacion)).setText("Direccion: " + c.getDireccion());
((TextView) infoWindows.findViewById(R.id.info_window_horario)).setText("Horario: " + c.getHorario());
return infoWindows;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
AYUDAAA :( !! I do not know what I'm doing wrong.