Mapsui logo

Mapsui

Community
znlgis
mapsui

Use when embedding interactive 2D maps in .NET desktop (WPF/WinUI/WinForms) or mobile (MAUI/Avalonia/Blazor) apps with Mapsui 5.1.0 (net8.0/net9.0) — Mapsui.Wpf/Mapsui.Maui packages, Map and Layers, OpenStreetMap.CreateTileLayer, Shapefile/GeoJSON via Mapsui.Nts, SphericalMercator.FromLonLat, or fixing a blank MapControl.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill namemapsui
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Mapsui AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/gis/mapsui
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/gis/mapsui .claude/skills/mapsui
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Mapsui in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Mapsui on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Mapsui is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址: https://github.com/Mapsui/Mapsui

官方文档: https://mapsui.com/v5/documentation/index.html

最新版本: 5.1.0(截至 2026-10,NuGet 稳定版;5.2.0-beta.1 为预发布)

许可证: MIT

概述

  • 跨 UI 框架:WPF / WinUI / MAUI / Avalonia / Uno / Blazor / WinForms
  • SkiaSharp 渲染,性能优于 GDI+
  • 数据源:OSM / WMS / WMTS / TMS / XYZ / Shapefile / GeoJSON / MBTiles / PostGIS
  • 几何基于 NetTopologySuite
  • 投影:ProjNet / Mapsui.Projections
  • 内置交互:拖动、缩放、旋转、捏合、命中

安装

bash
# 按 UI 框架选一个
dotnet add package Mapsui.Wpf --version 5.1.0      # WPF(net8.0-windows / net9.0-windows)
dotnet add package Mapsui.Maui --version 5.1.0     # MAUI,或 Mapsui.Avalonia / Mapsui.WinUI / Mapsui.Blazor
# 按数据源按需追加
dotnet add package Mapsui.Tiling --version 5.1.0   # 瓦片底图
dotnet add package Mapsui.Nts --version 5.1.0      # NTS 几何 / Shapefile

验证

bash
dotnet --list-sdks                        # 需 .NET 8/9 SDK
dotnet restore                            # 能解析 Mapsui 5.1.0 即包可用
dotnet build                              # 编译通过后才进入渲染验证

所有 Mapsui.* 子包版本必须一致(同样写 5.1.0),混版会在运行时抛类型加载异常。


WPF 入门

xml
<Window xmlns:mapsui="clr-namespace:Mapsui.UI.Wpf;assembly=Mapsui.UI.Wpf">
    <mapsui:MapControl x:Name="MapControl"/>
</Window>
csharp
using Mapsui;
using Mapsui.Tiling;
using Mapsui.Projections;

var map = new Map();
map.Layers.Add(OpenStreetMap.CreateTileLayer());

var pt = SphericalMercator.FromLonLat(116.397, 39.908).ToMPoint();
map.Navigator.CenterOnAndZoomTo(pt, map.Navigator.Resolutions[10]);

MapControl.Map = map;

核心概念

类型说明
Map地图
Layer / MemoryLayer / ImageLayer / TileLayer图层
IProvider数据提供者
IFeature / GeometryFeature要素(NTS 几何)
IStyle / VectorStyle / LabelStyle / SymbolStyle样式
Navigator视图操作

矢量图层

csharp
using Mapsui.Nts;
using Mapsui.Styles;
using NetTopologySuite.NtsGeometryServices;

// 视图坐标系为 EPSG:3857,经纬度数据必须先投影
var factory = NtsGeometryServices.Instance.CreateGeometryFactory(3857);

var features = new List<IFeature>
{
    new GeometryFeature(factory.CreatePoint(SphericalMercator.FromLonLat(116.397, 39.908).ToCoordinate()))
    {
        Styles = { new VectorStyle {
            Fill = new Brush(Color.Red),
            Outline = new Pen(Color.Black, 1)
        }}
    }
};

map.Layers.Add(new MemoryLayer("Roads") { Features = features, Style = null });

线/面要素用 factory.CreateLineString(coords) / factory.CreatePolygon(shell, holes),坐标同样要先 SphericalMercator.FromLonLat 投影。


Shapefile

csharp
using Mapsui.Nts.Providers.Shapefile;
var prov = new ShapeFile("china.shp", true);
map.Layers.Add(new Layer("China") { DataSource = prov });

瓦片图层

csharp
map.Layers.Add(OpenStreetMap.CreateTileLayer());

var src = new HttpTileSource(
    new GlobalSphericalMercator(0, 18),
    "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
    name: "AMap");
map.Layers.Add(new TileLayer(src) { Name = "AMap" });

// MBTiles
var mb = new MbTilesTileSource(new SQLiteConnectionString("city.mbtiles", false));
map.Layers.Add(new TileLayer(mb));

WMS

csharp
using Mapsui.Providers.Wms;
var wms = new WmsProvider("https://demo.mapserver.org/cgi-bin/wms?",
    new[] { "continents" });
map.Layers.Add(new ImageLayer("WMS") { DataSource = wms });

样式

csharp
new SymbolStyle { SymbolScale = 0.7, Fill = new Brush(Color.Red) };

new LabelStyle {
    Text = "{name}",
    Font = new Font { Size = 14 },
    BackColor = new Brush(Color.WhiteSmoke),
    Halo = new Pen(Color.White, 2)
};

主题样式

csharp
public class PopulationStyle : IThemeStyle {
    public IStyle? GetStyle(IFeature f) {
        var pop = (int)f["population"];
        return new VectorStyle { Fill = new Brush(pop > 1_000_000 ? Color.Red : Color.Blue) };
    }
}
layer.Style = new PopulationStyle();

交互

csharp
MapControl.Info += (s, e) => {
    if (e.MapInfo?.Feature is GeometryFeature gf)
        Debug.WriteLine($"clicked {gf["name"]}");
};

典型工作流

工作流 1:加载底图 + GeoJSON 矢量数据

输入 POI 记录(含 Lon / Lat / Name),输出 WPF 窗口里可拖拽缩放的底图 + 红色点图层。

csharp
using Mapsui;
using Mapsui.Tiling;
using Mapsui.Nts;
using Mapsui.Styles;
using Mapsui.Projections;

var map = new Map();

// 1. OSM 底图(来自 Mapsui.Tiling)
map.Layers.Add(OpenStreetMap.CreateTileLayer());

// 2. 构造点图层。Mapsui 的视图坐标系默认是 Web Mercator(EPSG:3857),
//    GeoJSON/业务数据里的经纬度必须先投影,否则会画到南太平洋附近。
var features = new List<IFeature>();
var factory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(3857);

foreach (var item in poiList)              // item:含 Lon / Lat / Name 的 POI 记录
{
    var p = SphericalMercator.FromLonLat(item.Lon, item.Lat).ToCoordinate();
    var feature = new GeometryFeature(factory.CreatePoint(p)) { ["name"] = item.Name };
    feature.Styles.Add(new SymbolStyle
    {
        SymbolScale = 0.8,
        Fill = new Brush(Color.Red),
        Outline = new Pen(Color.White, 1)
    });
    features.Add(feature);
}
var dataLayer = new MemoryLayer("Data") { Features = features, Style = null };
map.Layers.Add(dataLayer);

// 3. 定位到北京
var center = SphericalMercator.FromLonLat(116.4, 39.9).ToMPoint();
map.Navigator.CenterOnAndZoomTo(center, map.Navigator.Resolutions[10]);

MapControl.Map = map;   // 忘记这一步窗口就是空白

工作流 2:Shapefile + WMS 叠加

输入 data/china.shp 与返回 rivers 图层的 WMS,输出底图 + 行政界 + 河流栅格图层。

csharp
using Mapsui.Nts.Providers.Shapefile;
using Mapsui.Providers.Wms;

// 1. Shapefile 矢量层(需 Mapsui.Nts)
var shpProvider = new ShapeFile("data/china.shp", true);
map.Layers.Add(new Layer("China") { DataSource = shpProvider });

// 2. WMS 栅格层:构造参数依次为服务地址,图层名数组
var wmsProvider = new WmsProvider("https://geo.example.com/wms?", new[] { "rivers" });
map.Layers.Add(new ImageLayer("Rivers") { DataSource = wmsProvider });

map.ZoomToExtents();

验证产物:dotnet build 通过不等于出图。无头环境用 Mapsui.Rendering.Skia.MapRenderer 把 map 渲染成 PNG 再打开 PNG 检查;有窗口时请用户运行后提供截图。

性能优化

  1. 海量点 → RasterizingTileLayer 包一层(按瓦片预渲染)
  2. 优先 MemoryLayer + 缓存 Feature
  3. 异步加载 + await Layer.WaitForFinishedRefresh()
  4. 共享 Brush/Pen/Style 实例
  5. SkiaSharp 关闭抗锯齿对极小符号有性能提升

常见问题

问题解决
WPF 无图NuGet 缺 Mapsui.Wpf 或没设置 MapControl.Map
找不到 Mapsui.UI.Wpf 包NuGet 包名为 Mapsui.Wpf(v3 起启用该名称;程序集仍为 Mapsui.UI.Wpf.dll)
投影错误SphericalMercator.FromLonLat 转换
MAUI 空白MauiProgram 中 UseSkiaSharp() + UseMapsui()
Shapefile 中文乱码Mapsui 的 DBF 默认按 UTF-7 解析,中文会乱码:.dbf 缺 .cpg 声明时按实际编码赋值 new ShapeFile(path, true) { Encoding = Encoding.GetEncoding("GBK") }(属性赋值,不是构造参数)
GeometryFeature / 瓦片类型找不到矢量要素需安装 Mapsui.Nts,瓦片图层需安装 Mapsui.Tiling

AI 使用建议

  • 执行环境:先 dotnet --list-sdks;Mapsui 5.1.0 的目标框架是 net8.0/net9.0(Mapsui.Wpf 为 net8.0-windows/net9.0-windows),低于 .NET 8 的工程不能直接引用。命令在终端中执行,例如 dotnet add package Mapsui.Wpf --version 5.1.0。
  • 验证产物:dotnet build 只证明编译通过;无头渲染用 Mapsui.Rendering.Skia.MapRenderer.RenderToBitmapStream(map, ...) 输出 PNG 的 MemoryStream(参数以 IntelliSense 为准),落盘后打开 PNG 检查;WinForms/WPF 窗口 AI 助手 看不到,需用户运行后提供截图。
  • 投影:定位坐标必须 SphericalMercator.FromLonLat(lon, lat) 转换,直接用经纬度会定位到南太平洋。
  • 数据:Shapefile 中文要设 ShapeFile.Encoding(UTF8 或 GBK);矢量要素装 Mapsui.Nts,瓦片装 Mapsui.Tiling,UI 包装 Mapsui.Wpf/Mapsui.Maui。
  • 常见症状:MapControl 空白先查是否赋值 MapControl.Map;MAUI 空白查 UseSkiaSharp() 与 UseMapsui() 是否注册。
  • 安全与权限:新建工程、装包、运行桌面程序前先征得用户同意;PostGIS/瓦片服务的密码不要写进代码或回答。

相关技能

参考资源

Frequently asked questions

What does the Mapsui AI skill do?

Use when embedding interactive 2D maps in .NET desktop (WPF/WinUI/WinForms) or mobile (MAUI/Avalonia/Blazor) apps with Mapsui 5.1.0 (net8.0/net9.0) — Mapsui.Wpf/Mapsui.Maui packages, Map and Layers, OpenStreetMap.CreateTileLayer, Shapefile/GeoJSON via Mapsui.Nts, SphericalMercator.FromLonLat, or fixing a blank MapControl.

Why use Mapsui on TypingMind?

Because you install it once and use it with any model. Mapsui is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Mapsui in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/gis/mapsui. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Mapsui?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Mapsui?

As many as you like. As long as a model supports skills, you can use Mapsui with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Mapsui AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇