I am working on an Android app. I need to pass a map marker icon to its infowindow.
This is the method addMarker:
private void addMarker(LatLng latlng, final String title, final String nombre_apellidos, final String datosreporte,final String tiporeporte) {
markerOptions.position(latlng);
markerOptions.title(title);
markerOptions.snippet(nombre_apellidos+": "+datosreporte);
if (tiporeporte.equals("1")){
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.tipo_1));
}
else{
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_actihome));
}
mGoogleMap.addMarker(markerOptions).showInfoWindow();
mGoogleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Toast.makeText(getContext(), marker.getTitle(), Toast.LENGTH_SHORT).show();
}
});
}
And this is how I create the infowindow:
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
View v = null;
try {
// Getting view from the layout file info_window_layout
v = getLayoutInflater().inflate(R.layout.custominfowindow, null);
// Getting reference to the TextView to set latitude
TextView addressTxt = (TextView) v.findViewById(R.id.addressTxt);
TextView nameTxt = (TextView) v.findViewById(R.id.nameTxt);
ImageView icono = (ImageView) v.findViewById(R.id.iconoimagen);
addressTxt.setText(arg0.getTitle());
nameTxt.setText(arg0.getSnippet());
} catch (Exception ev) {
System.out.print(ev.getMessage());
}
return v;
}
I need to put the marker icon in the ImageView icono.
Thank you.