I'm trying to add the object's image passed to the custom pin in the InfoWindow to the left of the InfoWindow.
I have an app that calls an API and returns an object that has a name and an image and I want the InfoWindow's left icon to be the object's image but I don't know how to do it.
The left image.
Thank you for your help.
For Cole
CustomMapRenderer
public Android.Views.View GetInfoContents(Marker marker)
{
var inflater = Android.App.Application.Context.GetSystemService(Context.LayoutInflaterService) as Android.Views.LayoutInflater;
if (inflater != null)
{
Android.Views.View view;
var customPin = GetCustomPin(marker);
if (customPin == null)
{
throw new Exception("Custom pin not found");
}
view = inflater.Inflate(Resource.Layout.MapInfoWindow, null);
var infoTitle = view.FindViewById<TextView>(Resource.Id.InfoWindowTitle);
var infoSubtitle1 = view.FindViewById<TextView>(Resource.Id.InfoWindowSubtitle1);
ImageView image = view.FindViewById<ImageView>(Resource.Id.image);
Task.Run(() => {
URL url = new URL(customPin.Image);
var mIcon_val = BitmapFactory.DecodeStream(url.OpenConnection().InputStream);
image.SetImageBitmap(mIcon_val);
});
if (infoTitle != null)
{
infoTitle.Text = marker.Title;
}
if (infoSubtitle1 != null)
{
infoSubtitle1.Text = marker.Snippet;
}
return view;
}
return null;
}
MapInfoWindow
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="10dp">
<TextView
android:id="@+id/InfoWindowTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="InfoWindowTitle"
android:textColor="@android:color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/InfoWindowSubtitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="InfoWindowSubtitle1"
android:textColor="@android:color/black" />
</LinearLayout>
<ImageButton
android:id="@+id/InfoWindowButton"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/mtrl_btn_transparent_bg_color"
android:src="@drawable/icon_heart_red_24" />