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>
.NET 6-ios and .NET 6-android support isn't at this point supported, but considered preview. After we shipped Update 13, Microsoft updated their .NET 6 ios runtime with lots of breaking changes, which is what you're hitting.
We just shipped Update 13.1 a few days ago, and it's compiled with the latest, so (for now at least) that version should work with iOS (I've successfully used it). I have a MAUI sample here you can also play with and is quite similar to what you have: https://github.com/dotMorten/MauiPlayground/tree/main/Esri.ArcGISRuntime.Maui
Thanks Morten, I will update to v13.1 and get IOS up and running.
Good news! We have an official preview you can now use: https://community.esri.com/t5/arcgis-runtime-sdks-blog/announcing-preview-1-of-net-maui-support-with...
Hi Morten,
Wondering if anything in the latest updates might impact iOS showing a MapView. I'm at Visual Studio Version 17.3.0 Preview 3.0 and Runtime 100.14.1-preview3. I get a map to show up in Windows but not in iOS 15.5 simulator.
Thanks -Joe
There's a known issue with the ios simulator in 14.1. Please see the workaround I put here: https://community.esri.com/t5/arcgis-runtime-sdk-for-net-questions/ios-emulator-with-arcgisruntime-m...