How do I implement an InfoWindowAdapter interface

2019-08-12 17:43发布

问题:

I am using Xamarin and I am wanting to create a CustomWindowAdapter that implements a GoogleMap.InfoWindowAdapter interface.

I have tried this so far:

public class CustomWindowAdapter : InfoWindowAdapter
{

}

I am getting this error:

Error CS0246: The type or namespace name 'InfoWindowAdapter' could not be found (are you missing a using directive or an assembly reference?)

Here is the documentation for the interface: https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.InfoWindowAdapter

Can I please have some help?

What using statement do I need to use?

Thanks in advance

回答1:

Step 1: Get Google Play Services component from Component Store

Step 2: Implement GoogleMap.IInfoWindowAdapter

using Android.Gms.Maps;
using Android.Gms.Maps.Model;
using Android.Views;

public class InfoWindow : Java.Lang.Object, GoogleMap.IInfoWindowAdapter
{
    #region IInfoWindowAdapter implementation

    public View GetInfoContents(Marker p0)
    {
        throw new NotImplementedException ();
    }

    public View GetInfoWindow(Marker p0)
    {
        throw new NotImplementedException ();
    }

    #endregion
}