Tested with MAUI Preview 14 and ArcGIS Runtime for .NET 100.13
Works on Windows and Android, but not IOS.
Code to create a MapView control for use in MAUI, and map it to the ArcGIS Runtime MapView.
using Microsoft.Maui.Handlers;
using EsriMap = Esri.ArcGISRuntime.Mapping.Map;
namespace MauiApp;
public interface IMapView : IView
{
EsriMap Map { get; set; }
}
public class MapView : View, IMapView
{
public static readonly BindableProperty MapProperty = BindableProperty.Create(
nameof(Map), typeof(EsriMap), typeof(MapView));
public EsriMap Map
{
get => (EsriMap)GetValue(MapProperty);
set => SetValue(MapProperty, value);
}
}
public class MapViewHandler : ViewHandler<IMapView, Esri.ArcGISRuntime.UI.Controls.MapView>
{
public MapViewHandler() : base(PropertyMapper, CommandMapper)
{
}
public static readonly PropertyMapper<IMapView, MapViewHandler> PropertyMapper = new PropertyMapper<IMapView, MapViewHandler>(ViewMapper)
{
[nameof(IMapView.Map)] = MapMap
};
public static readonly CommandMapper<IButton, IButtonHandler> CommandMapper = new CommandMapper<IButton, IButtonHandler>(ViewCommandMapper);
private static void MapMap(MapViewHandler handler, IMapView view)
{
handler.PlatformView.Map = view.Map;
}
protected override Esri.ArcGISRuntime.UI.Controls.MapView CreatePlatformView()
{
#if ANDROID
return new Esri.ArcGISRuntime.UI.Controls.MapView(Context);
#else
return new Esri.ArcGISRuntime.UI.Controls.MapView();
#endif
}
}
Register with MAUI app builder in MauiProgram.cs
ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(MapView), typeof(MapViewHandler));
});
Add ArcGIS Runtime NuGet packages.
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<PackageReference Include="Esri.ArcGISRuntime.WinUI" Version="100.13.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="Esri.ArcGISRuntime.Xamarin.Android" Version="100.13.0" />
</ItemGroup>