AppHostBuilderExtensions.UseMauiMaps(MauiAppBuilder) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
MapIconon aMapElementsLayer.
Windows Platform Limitations:
- User Location: Not built-in; requires manual Geolocation API integration.
- Shapes: Polylines, polygons, and circles are not supported (
MapElementsLayeronly supportsMapIcon). - Pin Labels:
MapIcondoes not support labels or info windows. - Map.Clicked (background): Only
MapElementclicks fire events, not empty map area clicks.