maui-maps

在 .NET MAUI 应用中使用 Microsoft.Maui.Controls.Maps 的地图指南。涵盖添加地图控件、图钉、多边形、折线、地理编码、Google Maps API 密钥配置与平台设置,以及地图初始化、反向地理编码与地图区域设置等场景。适用场景包括地图控件、地图图钉、多边形与折线、地理编码和 Google Maps API 密钥配置。非适用:获取设备 GPS 坐标(请使用 maui-geolocation)、自定义绘制覆盖层(请使用 maui-graphics-drawing)、仅位置权限处理(请使用 maui-permissions)。

仓库最近推送
GitHub Stars
181
Forks
21
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-maps":https://skillpi.com/zh/skills/deepskill-5f8690d26ffcfd76232890abda66a8f8a341138205e0d31addce2d1b0ce49d26。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

在 .NET MAUI 应用中使用 Microsoft.Maui.Controls.Maps 的地图指南。涵盖添加地图控件、图钉、多边形、折线、地理编码、Google Maps API 密钥配置与平台设置,以及地图初始化、反向地理编码与地图区域设置等场景。适用场景包括地图控件、地图图钉、多边形与折线、地理编码和 Google Maps API 密钥配置。非适用:获取设备 GPS 坐标(请使用 maui-geolocation)、自定义绘制覆盖层(请使用 maui-graphics-drawing)、仅位置权限处理(请使用 maui-permissions)。

0 下载

介绍来源: third_party · davidortinau · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: maui-maps
description: >
  Guidance for adding map controls, pins, polygons, polylines, geocoding,
  Google Maps API key configuration, and platform setup in .NET MAUI apps
  using Microsoft.Maui.Controls.Maps.
  USE FOR: "add map", "map control", "map pins", "polygons on map", "polylines",
  "geocoding", "Google Maps API key", "Microsoft.Maui.Controls.Maps", "map setup",
  "reverse geocoding", "map region".
  DO NOT USE FOR: getting device GPS coordinates (use maui-geolocation),
  custom drawing overlays (use maui-graphics-drawing), or location permissions only (use maui-permissions).

.NET MAUI Maps

Common gotchas

Issue Fix
Map is blank on Android Google Maps API key missing or wrong in AndroidManifest.xml
Map crashes on startup .UseMauiMaps() not called in MauiProgram.cs
Map type ambiguous Conflicts with Microsoft.Maui.ApplicationModel.Map — add namespace alias
Map doesn't show on Windows Windows has no native support — must use CommunityToolkit.Maui.Maps
User location dot missing IsShowingUser="True" set but location permission not granted
Android 11+ can't launch external map app Missing <queries> for geo scheme in manifest

⚠️ Name conflict — always alias

Microsoft.Maui.Controls.Maps.Map conflicts with Microsoft.Maui.ApplicationModel.Map. This causes confusing compile errors.

// ✅ Correct — explicit alias
using Map = Microsoft.Maui.Controls.Maps.Map;
<!-- ✅ Correct — namespace prefix in XAML -->
xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps"
<maps:Map ... />

<!-- ❌ Wrong — bare <Map> is ambiguous -->
<Map ... />

Platform setup pitfalls

Android — API key must be inside <application>

<!-- ✅ Correct -->
<application ...>
  <meta-data android:name="com.google.android.geo.API_KEY"
             android:value="YOUR_GOOGLE_MAPS_KEY" />
</application>

<!-- ❌ Outside <application> — key is silently ignored -->

⚠️ Also required: Google Play Services version meta-data and <queries> for geo scheme on API 30+ (see references/maps-api.md).

iOS / Mac Catalyst

⚠️ Without NSLocationWhenInUseUsageDescription in Info.plist, location permission is denied without prompt.

Windows — no native support

Must add CommunityToolkit.Maui.Maps + Bing key. Use conditional package reference and #if WINDOWS for setup.

MauiProgram.cs — don't forget UseMauiMaps

// ✅ Required — without this, Map control throws at runtime
builder.UseMauiMaps();

// ❌ Forgetting this causes "No registered handler for Map" crash

Performance tips

  • ⚠️ Don't add hundreds of pins directly — use ItemsSource with data binding for large pin sets.
  • Set initial region with MoveToRegion() to avoid the default world view zoom animation.
  • Avoid frequent MoveToRegion() calls — each triggers a map animation; debounce if driven by data changes.

Data-bound pins — do this for dynamic data

<!-- ✅ Correct — data-bound pins for dynamic collections -->
<maps:Map ItemsSource="{Binding Locations}">
    <maps:Map.ItemTemplate>
        <DataTemplate>
            <maps:Pin Label="{Binding Name}"
                      Address="{Binding Description}"
                      Location="{Binding Position}" />
        </DataTemplate>
    </maps:Map.ItemTemplate>
</maps:Map>

<!-- ❌ Wrong — manually adding pins in code-behind for data-driven scenarios -->

Decision framework

Need Approach
Basic map with pins Map control + Pins.Add() or ItemsSource binding
Map with shapes MapElements — Polygon, Polyline, Circle
Address → coordinates Geocoding.Default.GetLocationsAsync(address)
Coordinates → address Geocoding.Default.GetPlacemarksAsync(lat, lon)
Custom map overlays Use handlers to access native map APIs
Windows support Must add CommunityToolkit.Maui.Maps + Bing key

Quick checklist

  • [ ] NuGet: Microsoft.Maui.Controls.Maps added
  • [ ] .UseMauiMaps() called in MauiProgram.cs
  • [ ] Android: Google Maps API key inside <application> in AndroidManifest.xml
  • [ ] Android: Google Play Services version meta-data present
  • [ ] Android 11+: <queries> for geo scheme added
  • [ ] iOS/Mac: NSLocationWhenInUseUsageDescription in Info.plist
  • [ ] Windows: CommunityToolkit.Maui.Maps + Bing Maps key (conditional)
  • [ ] Namespace alias added to avoid Map type conflict

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 .NET MAUI 地图控件的完整端到端使用指南,涵盖多平台配置与常见陷阱解决方案
  • 明确区分适用与不适用场景,帮助用户精准选择工具
触发精准90/100

亮点

  • 触发词覆盖全面,包含地图控件、图钉、地理编码等核心功能关键词
  • 明确排除 GPS 坐标获取等易混淆场景,边界清晰
结构规范95/100

待提升项

  • 文档长度略长 原报告严重程度:轻微

    主文档约600行,可能影响阅读体验

    改进建议:建议增加目录导航或将部分内容移至子文档

亮点

  • 结构清晰,包含常见陷阱、平台设置、性能提示、决策框架和检查清单
  • 提供大量可复用的代码示例和最佳实践
执行可靠90/100

亮点

  • 工具来源明确(Microsoft.Maui.Controls.Maps、CommunityToolkit.Maui.Maps)
  • 覆盖主要异常场景(API密钥缺失、权限问题、平台差异)并提供具体修复方案
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。