AppHostBuilderExtensions.UseMauiMaps(MauiAppBuilder) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定 MauiAppBuilder 以新增控件的支援 Map 。
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
參數
- builder
- MauiAppBuilder
MauiAppBuilder要設定。
例外狀況
Windows之所以被丟到Windows,是因為地圖控制目前還沒實作。
備註
Windows(Azure 地圖服務):請使用以下方式ConfigureEssentials設定您的 Azure 地圖服務 訂閱金鑰:
builder.ConfigureEssentials(essentials => essentials.UseMapServiceToken("YOUR_AZURE_MAPS_KEY"));
從Azure 入口網站取得一把金鑰: https://portal.azure.com → Azure 地圖服務帳號→認證
Windows 功能(透過 Azure 地圖服務 JS API):Windows 實作使用 WinUI 3 MapControl,並由 Azure 地圖服務 支援。 以下功能可透過控制項內部的 WebView2 存取Azure 地圖服務 JavaScript API來實現:
-
MoveToRegion: 導航方式為
map.setCamera()。 -
地圖類型: 街道/衛星/混合動力車透過
map.setStyle()。 -
IsTrafficEnabled: 交通流量與事件透過
map.setTraffic()。 -
IsScrollEnabled/IsZoomEnabled:透過 獨立控制。
map.setUserInteraction() -
別針: 經由
MapIconMapElementsLayer.
Windows 平台限制:
- 使用者所在地: 不是內建的;需要手動整合地理定位 API。
-
形狀: 多邊形、多邊形和圓形不被支撐(
MapElementsLayer只MapIcon支撐)。 -
徽章標籤:
MapIcon不支援標籤或資訊視窗。 -
地圖。點擊(背景): 只
MapElement點擊射擊事件,不會點擊空白地圖區域的點擊。