AppHostBuilderExtensions.UseMauiMaps(MauiAppBuilder) Method

Definition

Configures MauiAppBuilder to add support for the Map control.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Maui::Hosting::MauiAppBuilder ^ UseMauiMaps(Microsoft::Maui::Hosting::MauiAppBuilder ^ builder);
public static Microsoft.Maui.Hosting.MauiAppBuilder UseMauiMaps(this Microsoft.Maui.Hosting.MauiAppBuilder builder);
static member UseMauiMaps : Microsoft.Maui.Hosting.MauiAppBuilder -> Microsoft.Maui.Hosting.MauiAppBuilder
<Extension()>
Public Function UseMauiMaps (builder As MauiAppBuilder) As MauiAppBuilder

Parameters

builder
MauiAppBuilder

The MauiAppBuilder to configure.

Exceptions

Thrown on Windows because the maps control currently is not implemented for Windows.

Remarks

Windows (Azure Maps): Set your Azure Maps subscription key using ConfigureEssentials:

builder.ConfigureEssentials(essentials => essentials.UseMapServiceToken("YOUR_AZURE_MAPS_KEY"));

Get a key from the Azure Portal: https://portal.azure.com → Azure Maps account → Authentication

Windows Features (via Azure Maps JS API): The Windows implementation uses the WinUI 3 MapControl backed by Azure Maps. The following features are implemented by accessing the Azure Maps JavaScript API through the control's internal WebView2:

  • MoveToRegion: Navigates via map.setCamera().
  • MapType: Street/Satellite/Hybrid via map.setStyle().
  • IsTrafficEnabled: Traffic flow and incidents via map.setTraffic().
  • IsScrollEnabled/IsZoomEnabled: Independent control via map.setUserInteraction().
  • Pins: Via MapIcon on a MapElementsLayer.

Windows Platform Limitations:

  • User Location: Not built-in; requires manual Geolocation API integration.
  • Shapes: Polylines, polygons, and circles are not supported (MapElementsLayer only supports MapIcon).
  • Pin Labels: MapIcon does not support labels or info windows.
  • Map.Clicked (background): Only MapElement clicks fire events, not empty map area clicks.
See MapHandler documentation for detailed platform information.

Applies to