0

The first time you load the code, a map with several markers is displayed when you click on one, a dialog box appears where you must load the respective image of the object you sent, however the first time you load the markers when you press the marker to to show me the image does not load it, but if I close and return to open that marker the 2nd time and load it well

I was testing with the methods you have to see if I do the load or if you had an error, when you try it, in all accesses to the method it says that this

public class CustomInfoWindowGoogleMap implements GoogleMap.InfoWindowAdapter {

    private Context context;
    private String url;

    public CustomInfoWindowGoogleMap(Context ctx){
        context = ctx;
    }

    @Override
    public View getInfoWindow(Marker marker){
        return null;
    }

    @Override
    public View getInfoContents(Marker marker){
        View view = ((Activity)context).getLayoutInflater().inflate(R.layout.info_window_layout, null);
        VistaTrEstablecimientoDto infoWindowData = (VistaTrEstablecimientoDto) marker.getTag();
        url = infoWindowData.getUrl_imagen();
        TextView wl_nombre = view.findViewById(R.id.wl_Nombre);
        ImageView wl_imagenView = view.findViewById(R.id.wl_image);
        Picasso.with((Activity)context).load(url).resize(80, 80).into(wl_imagenView);
        TextView wl_descripcionCorta = view.findViewById(R.id.wl_DescripcionCorta);
        TextView wl_direccion = view.findViewById(R.id.wl_Direccion);
        TextView wl_horario = view.findViewById(R.id.wl_horario);
        wl_nombre.setText(infoWindowData.getNombre());
        wl_descripcionCorta.setText(infoWindowData.getDescripcionCorta());
        wl_direccion.setText(infoWindowData.getDireccion());
        wl_horario.setText(infoWindowData.getHorario());
        return view;
    }

}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="5dp">

    <ImageView
        android:id="@+id/wl_image"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:scaleType="centerCrop" />

    <TextView
        android:id="@+id/wl_Nombre"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:textStyle="bold"
        android:layout_toRightOf="@id/wl_image"
        android:paddingLeft="5dp" />

    <TextView
        android:id="@+id/wl_DescripcionCorta"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/wl_Nombre"
        android:layout_toRightOf="@id/wl_image"
        android:paddingLeft="5dp" />

    <TextView
        android:id="@+id/wl_Direccion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/wl_DescripcionCorta"
        android:layout_toRightOf="@id/wl_image"
        android:paddingLeft="5dp" />

    <TextView
        android:id="@+id/wl_horario"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/wl_Direccion"
        android:layout_toRightOf="@id/wl_image"
        android:paddingLeft="5dp" />

    <Button
        android:id="@+id/wl_reservar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/wl_horario"
        android:text = "Reservar"
        android:gravity="center" />

</RelativeLayout>
  • 1
    Possible duplicate of [infoWindow's image now showing on first click, but it works on second click](https://stackoverflow.com/questions/30186982/infowindows-image-now-showing-on-first-click-but-it-works-on-second-click) – ADM Apr 10 '19 at 04:00
  • The Problem here is `InfoWindow` is Drawing cache of the view you have provided . Since loading image is an asynchronous task and it takes time this is why it does not show in first attempt . Read https://developers.google.com/maps/documentation/android-sdk/infowindows. – ADM Apr 10 '19 at 04:02

0 Answers0