syncfusion-winforms-map

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementing Maps in Windows Forms

在Windows Forms中实现地图功能

The Syncfusion WinForms Maps control is a powerful geographical data visualization component that renders shape files and displays statistical information with interactive features like zooming, panning, tooltips, and selection.
Syncfusion WinForms Maps控件是一款强大的地理数据可视化组件,可渲染shape文件,并通过缩放、平移、提示框、选中效果等交互功能展示统计信息。

When to Use This Skill

何时使用本指南

Use the Maps control when you need to:
  • Geographical Visualization: Display geographical data on world maps, country maps, or regional maps
  • Statistical Maps: Create choropleth maps showing statistical data by region (population, sales, demographics)
  • Bubble Maps: Visualize data using bubbles of varying sizes on map locations
  • Multi-Layer Maps: Combine multiple geographical layers (e.g., world map with highlighted regions)
  • Interactive Maps: Enable user interaction with tooltips, selection, zooming, and panning
  • Dashboard Integration: Add map visualizations to desktop dashboard applications
  • Location Analytics: Build applications that analyze and display location-based data
当你需要实现以下需求时可以使用Maps控件:
  • 地理可视化:在世界地图、国家地图或区域地图上展示地理数据
  • 统计地图:创建choropleth地图,按区域展示统计数据(人口、销售额、人口统计数据)
  • 气泡地图:在地图位置上使用不同大小的气泡对数据进行可视化
  • 多层地图:组合多个地理图层(例如带有高亮区域的世界地图)
  • 交互式地图:支持用户通过提示框、选中、缩放、平移进行交互
  • 仪表盘集成:为桌面仪表盘应用添加地图可视化能力
  • 位置分析:构建用于分析和展示基于位置的数据的应用

Component Overview

组件概览

Key Features:
  • Shape file rendering (.shp, .dbf, .shx)
  • Multiple layer support with SubShapeFileLayers
  • Data binding with ItemSource
  • Bubble visualization with size and color mapping
  • Legend support with customizable positioning
  • Interactive features: tooltips, selection, zooming, panning
  • Annotations for custom markers
  • Extensive customization options for colors, strokes, and fills
核心特性:
  • shape文件渲染(.shp、.dbf、.shx格式)
  • 支持多图层与SubShapeFileLayers
  • 支持通过ItemSource进行数据绑定
  • 支持气泡可视化,可配置大小与颜色映射
  • 支持图例,可自定义位置
  • 交互特性:提示框、选中、缩放、平移
  • 支持自定义标记注解
  • 丰富的颜色、边框、填充自定义选项

Documentation and Navigation Guide

文档与导航指南

Getting Started

入门指南

📄 Read: references/getting-started.md
  • Assembly deployment and NuGet installation
  • Key concepts and map structure
  • Shape file description and requirements
  • Adding shape files as embedded resources
  • Uri property configuration
  • Creating your first map
  • Basic implementation example
📄 阅读: references/getting-started.md
  • 程序集部署与NuGet安装
  • 核心概念与地图结构
  • shape文件说明与要求
  • 将shape文件添加为嵌入式资源
  • Uri属性配置
  • 创建你的第一个地图
  • 基础实现示例

Layers and Shape Files

图层与Shape文件

📄 Read: references/layers.md
  • ShapeFileLayer architecture
  • Adding multiple layers (MultiLayer support)
  • SubShapeFileLayer usage
  • LayoutType configuration (Default vs Tile)
  • ItemSource data binding
  • ShapeIDPath and ShapeIDTableField mapping
  • Layer customization
📄 阅读: references/layers.md
  • ShapeFileLayer架构
  • 添加多图层(多层支持)
  • SubShapeFileLayer使用方法
  • LayoutType配置(默认 vs 瓦片)
  • ItemSource数据绑定
  • ShapeIDPath与ShapeIDTableField映射
  • 图层自定义

Bubbles

气泡

📄 Read: references/bubbles.md
  • Adding bubbles to maps
  • BubbleSetting properties (AutoFillColors, MaxSize, MinSize)
  • ValuePath and ColorValuePath configuration
  • Range color mapping for bubbles
  • StrokeThickness and Fill customization
  • Bubble visualization examples
📄 阅读: references/bubbles.md
  • 为地图添加气泡
  • BubbleSetting属性(AutoFillColors、MaxSize、MinSize)
  • ValuePath与ColorValuePath配置
  • 气泡范围颜色映射
  • StrokeThickness与Fill自定义
  • 气泡可视化示例

Legends

图例

📄 Read: references/legends.md
  • Legend visibility (ShowLegend)
  • Legend positioning (Position, PositionX, PositionY)
  • Legend header and title
  • Legend categories (layers vs bubbles)
  • LegendType and LegendIcon
  • Legend shape customization
📄 阅读: references/legends.md
  • 图例可见性(ShowLegend)
  • 图例位置(Position、PositionX、PositionY)
  • 图例头部与标题
  • 图例分类(图层 vs 气泡)
  • LegendType与LegendIcon
  • 图例形状自定义

User Interaction

用户交互

📄 Read: references/user-interaction.md
  • Tooltip support (ShowToolTip)
  • Single and multiple selection
  • EnableSelection and SelectionMode
  • SelectedShapeColor customization
  • Zooming with ZoomFactor and ZoomLevel
  • Panning and navigation
  • ShapeSelected event handling
📄 阅读: references/user-interaction.md
  • 提示框支持(ShowToolTip)
  • 单选与多选
  • EnableSelection与SelectionMode
  • SelectedShapeColor自定义
  • 通过ZoomFactor与ZoomLevel实现缩放
  • 平移与导航
  • ShapeSelected事件处理

Map Points

地图点

📄 Read: references/map-points.md
  • Point shape files and geometries
  • Loading point data layers
  • Point vs polygon vs polyline shapes
  • Styling point markers
  • Point data binding
  • Multiple point layers
📄 阅读: references/map-points.md
  • 点shape文件与几何图形
  • 加载点数据图层
  • 点、多边形、折线形状对比
  • 点标记样式设置
  • 点数据绑定
  • 多个点图层

Annotations

注解

📄 Read: references/annotations.md
  • Adding custom annotations
  • Latitude and Longitude positioning
  • AnnotationDrawing event
  • Custom markers and icons
  • Annotation collections
  • Drawing custom graphics on maps
📄 阅读: references/annotations.md
  • 添加自定义注解
  • 经纬度定位
  • AnnotationDrawing事件
  • 自定义标记与图标
  • 注解集合
  • 在地图上绘制自定义图形

Customization

自定义

📄 Read: references/customization.md
  • Map appearance styling
  • Shape fill and stroke customization
  • Color value paths
  • FillSetting configuration
  • ColorMappings for ranges
  • Theme integration
  • Advanced styling techniques
📄 阅读: references/customization.md
  • 地图外观样式设置
  • 形状填充与边框自定义
  • 颜色值路径
  • FillSetting配置
  • 范围ColorMappings
  • 主题集成
  • 高级样式技巧

Quick Start

快速开始

Step 1: Install NuGet Package

步骤1:安装NuGet包

bash
Install-Package Syncfusion.Maps.WinForms
bash
Install-Package Syncfusion.Maps.WinForms

Step 2: Add Shape Files to Project

步骤2:向项目添加Shape文件

  1. Add shape files (e.g.,
    world1.shp
    ,
    world1.dbf
    ,
    world1.shx
    ) to your project
  2. Select files in Solution Explorer
  3. Set Build Action to Embedded Resource
  4. Set Copy to Output Directory to Copy if newer (optional)
  1. 向项目添加shape文件(例如
    world1.shp
    world1.dbf
    world1.shx
  2. 在解决方案资源管理器中选中文件
  3. 生成操作设置为嵌入式资源
  4. 复制到输出目录设置为如果较新则复制(可选)

Step 3: Basic Map Implementation

步骤3:基础地图实现

csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Maps;

namespace WinFormsMapsExample
{
    public partial class Form1 : Form
    {
        private Maps mapsControl;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // Create Maps control
            mapsControl = new Maps();
            mapsControl.Name = "mapsControl";
            mapsControl.Size = new Size(880, 585);
            mapsControl.Dock = DockStyle.Fill;
            mapsControl.MapBackgroundBrush = new SolidBrush(Color.White);

            // Create and configure shape layer
            ShapeFileLayer shapeLayer = new ShapeFileLayer();
            shapeLayer.Uri = "world1.shp";  // Shape file name
            
            // Add layer to map
            mapsControl.Layers.Add(shapeLayer);
            
            // Add control to form
            this.Controls.Add(mapsControl);
        }
    }
}
csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Maps;

namespace WinFormsMapsExample
{
    public partial class Form1 : Form
    {
        private Maps mapsControl;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // 创建Maps控件
            mapsControl = new Maps();
            mapsControl.Name = "mapsControl";
            mapsControl.Size = new Size(880, 585);
            mapsControl.Dock = DockStyle.Fill;
            mapsControl.MapBackgroundBrush = new SolidBrush(Color.White);

            // 创建并配置shape图层
            ShapeFileLayer shapeLayer = new ShapeFileLayer();
            shapeLayer.Uri = "world1.shp";  // Shape文件名称
            
            // 向地图添加图层
            mapsControl.Layers.Add(shapeLayer);
            
            // 向窗体添加控件
            this.Controls.Add(mapsControl);
        }
    }
}

Common Patterns

常用模式

Pattern 1: Data-Bound Map with Statistical Visualization

模式1:带统计可视化的数据绑定地图

csharp
private void CreateDataBoundMap()
{
    // Prepare data
    MapViewModel model = new MapViewModel();
    
    // Create shape layer
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    
    // Bind data
    shapeLayer.ItemSource = model.Countries;
    shapeLayer.ShapeIDPath = "NAME";            // Property in data model
    shapeLayer.ShapeIDTableField = "NAME";      // Column in .dbf file
    
    // Configure shape display
    shapeLayer.ShapeSetting.ShapeValuePath = "Population";
    shapeLayer.ShapeSetting.ShapeColorValuePath = "Population";
    shapeLayer.ShapeSetting.ShapeDisplayValuePath = "NAME";
    
    // Style settings
    shapeLayer.ShapeSetting.ShapeFill = "#E5E5E5";
    shapeLayer.ShapeSetting.ShapeStroke = "#C1C1C1";
    shapeLayer.ShapeSetting.ShapeStrokeThickness = 1.5;
    
    // Enable features
    shapeLayer.ShowToolTip = true;
    shapeLayer.EnableSelection = true;
    
    mapsControl.Layers.Add(shapeLayer);
}

// Data Model
public class Country
{
    public string NAME { get; set; }
    public double Population { get; set; }
}
csharp
private void CreateDataBoundMap()
{
    // 准备数据
    MapViewModel model = new MapViewModel();
    
    // 创建shape图层
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    
    // 绑定数据
    shapeLayer.ItemSource = model.Countries;
    shapeLayer.ShapeIDPath = "NAME";            // 数据模型中的属性
    shapeLayer.ShapeIDTableField = "NAME";      // .dbf文件中的列
    
    // 配置形状展示
    shapeLayer.ShapeSetting.ShapeValuePath = "Population";
    shapeLayer.ShapeSetting.ShapeColorValuePath = "Population";
    shapeLayer.ShapeSetting.ShapeDisplayValuePath = "NAME";
    
    // 样式设置
    shapeLayer.ShapeSetting.ShapeFill = "#E5E5E5";
    shapeLayer.ShapeSetting.ShapeStroke = "#C1C1C1";
    shapeLayer.ShapeSetting.ShapeStrokeThickness = 1.5;
    
    // 启用功能
    shapeLayer.ShowToolTip = true;
    shapeLayer.EnableSelection = true;
    
    mapsControl.Layers.Add(shapeLayer);
}

// 数据模型
public class Country
{
    public string NAME { get; set; }
    public double Population { get; set; }
}

Pattern 2: Multi-Layer Map

模式2:多层地图

csharp
private void CreateMultiLayerMap()
{
    // Base world layer
    ShapeFileLayer worldLayer = new ShapeFileLayer();
    worldLayer.Uri = "world1.shp";
    worldLayer.ShapeSetting.ShapeFill = "#E5E5E5";
    worldLayer.ShapeSetting.ShapeStroke = "#C1C1C1";
    worldLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // Highlighted region 1
    SubShapeFileLayer africaLayer = new SubShapeFileLayer();
    africaLayer.Uri = "africa.shp";
    africaLayer.ShapeSetting.ShapeFill = "#8DCEFF";
    africaLayer.ShapeSetting.ShapeStroke = "#2F8CEA";
    africaLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // Highlighted region 2
    SubShapeFileLayer australiaLayer = new SubShapeFileLayer();
    australiaLayer.Uri = "australia.shp";
    australiaLayer.ShapeSetting.ShapeFill = "#FFA07A";
    australiaLayer.ShapeSetting.ShapeStroke = "#FF6347";
    australiaLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // Add sublayers to main layer
    worldLayer.SubShapeFileLayers.Add(africaLayer);
    worldLayer.SubShapeFileLayers.Add(australiaLayer);
    
    mapsControl.Layers.Add(worldLayer);
}
csharp
private void CreateMultiLayerMap()
{
    // 基础世界图层
    ShapeFileLayer worldLayer = new ShapeFileLayer();
    worldLayer.Uri = "world1.shp";
    worldLayer.ShapeSetting.ShapeFill = "#E5E5E5";
    worldLayer.ShapeSetting.ShapeStroke = "#C1C1C1";
    worldLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // 高亮区域1
    SubShapeFileLayer africaLayer = new SubShapeFileLayer();
    africaLayer.Uri = "africa.shp";
    africaLayer.ShapeSetting.ShapeFill = "#8DCEFF";
    africaLayer.ShapeSetting.ShapeStroke = "#2F8CEA";
    africaLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // 高亮区域2
    SubShapeFileLayer australiaLayer = new SubShapeFileLayer();
    australiaLayer.Uri = "australia.shp";
    australiaLayer.ShapeSetting.ShapeFill = "#FFA07A";
    australiaLayer.ShapeSetting.ShapeStroke = "#FF6347";
    australiaLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

    // 向主图层添加子图层
    worldLayer.SubShapeFileLayers.Add(africaLayer);
    worldLayer.SubShapeFileLayers.Add(australiaLayer);
    
    mapsControl.Layers.Add(worldLayer);
}

Pattern 3: Bubble Map with Color Ranges

模式3:带颜色范围的气泡地图

csharp
private void CreateBubbleMap()
{
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    shapeLayer.ItemSource = GetCountries();
    shapeLayer.ShapeIDPath = "NAME";
    shapeLayer.ShapeIDTableField = "NAME";

    // Configure bubbles
    shapeLayer.BubbleSetting.AutoFillColors = false;
    shapeLayer.BubbleSetting.MaxSize = 70;
    shapeLayer.BubbleSetting.MinSize = 25;
    shapeLayer.BubbleSetting.ValuePath = "Population";
    shapeLayer.BubbleSetting.ColorValuePath = "Population";

    // Define color ranges
    shapeLayer.BubbleSetting.ColorMappings = 
        new System.Collections.ObjectModel.ObservableCollection<ColorMapping>
        {
            new RangeColorMapping 
            { 
                From = 1000000000, 
                To = 2000000000, 
                Color = Color.FromArgb(127, 32, 188, 238) 
            },
            new RangeColorMapping 
            { 
                From = 500000000, 
                To = 1000000000, 
                Color = Color.FromArgb(127, 167, 206, 56) 
            },
            new RangeColorMapping 
            { 
                From = 100000000, 
                To = 500000000, 
                Color = Color.FromArgb(127, 241, 178, 26) 
            },
            new RangeColorMapping 
            { 
                From = 0, 
                To = 100000000, 
                Color = Color.FromArgb(127, 235, 115, 124) 
            }
        };

    mapsControl.Layers.Add(shapeLayer);
}
csharp
private void CreateBubbleMap()
{
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    shapeLayer.ItemSource = GetCountries();
    shapeLayer.ShapeIDPath = "NAME";
    shapeLayer.ShapeIDTableField = "NAME";

    // 配置气泡
    shapeLayer.BubbleSetting.AutoFillColors = false;
    shapeLayer.BubbleSetting.MaxSize = 70;
    shapeLayer.BubbleSetting.MinSize = 25;
    shapeLayer.BubbleSetting.ValuePath = "Population";
    shapeLayer.BubbleSetting.ColorValuePath = "Population";

    // 定义颜色范围
    shapeLayer.BubbleSetting.ColorMappings = 
        new System.Collections.ObjectModel.ObservableCollection<ColorMapping>
        {
            new RangeColorMapping 
            { 
                From = 1000000000, 
                To = 2000000000, 
                Color = Color.FromArgb(127, 32, 188, 238) 
            },
            new RangeColorMapping 
            { 
                From = 500000000, 
                To = 1000000000, 
                Color = Color.FromArgb(127, 167, 206, 56) 
            },
            new RangeColorMapping 
            { 
                From = 100000000, 
                To = 500000000, 
                Color = Color.FromArgb(127, 241, 178, 26) 
            },
            new RangeColorMapping 
            { 
                From = 0, 
                To = 100000000, 
                Color = Color.FromArgb(127, 235, 115, 124) 
            }
        };

    mapsControl.Layers.Add(shapeLayer);
}

Pattern 4: Interactive Map with Events

模式4:带事件的交互式地图

csharp
private void CreateInteractiveMap()
{
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    shapeLayer.ItemSource = GetCountries();
    shapeLayer.ShapeIDPath = "Country";
    shapeLayer.ShapeIDTableField = "NAME";
    
    // Enable interaction
    shapeLayer.ShowToolTip = true;
    shapeLayer.EnableSelection = true;
    shapeLayer.SelectionMode = SelectionModes.Multiple;
    
    // Style selected shapes
    shapeLayer.ShapeSetting.SelectedShapeColor = Color.Orange;
    
    // Enable zooming
    mapsControl.ZoomFactor = 1.0f;
    mapsControl.ZoomLevel = 1;
    
    // Subscribe to events
    mapsControl.ShapeSelected += MapsControl_ShapeSelected;
    
    mapsControl.Layers.Add(shapeLayer);
}

private void MapsControl_ShapeSelected(object sender, ShapeSelectedEventArgs e)
{
    if (e.Data != null)
    {
        foreach (Country country in e.Data)
        {
            Console.WriteLine($"Selected: {country.Country}");
        }
    }
}
csharp
private void CreateInteractiveMap()
{
    ShapeFileLayer shapeLayer = new ShapeFileLayer();
    shapeLayer.Uri = "world1.shp";
    shapeLayer.ItemSource = GetCountries();
    shapeLayer.ShapeIDPath = "Country";
    shapeLayer.ShapeIDTableField = "NAME";
    
    // 启用交互
    shapeLayer.ShowToolTip = true;
    shapeLayer.EnableSelection = true;
    shapeLayer.SelectionMode = SelectionModes.Multiple;
    
    // 选中形状样式
    shapeLayer.ShapeSetting.SelectedShapeColor = Color.Orange;
    
    // 启用缩放
    mapsControl.ZoomFactor = 1.0f;
    mapsControl.ZoomLevel = 1;
    
    // 订阅事件
    mapsControl.ShapeSelected += MapsControl_ShapeSelected;
    
    mapsControl.Layers.Add(shapeLayer);
}

private void MapsControl_ShapeSelected(object sender, ShapeSelectedEventArgs e)
{
    if (e.Data != null)
    {
        foreach (Country country in e.Data)
        {
            Console.WriteLine($"Selected: {country.Country}");
        }
    }
}

Key Properties

核心属性

Maps Control Properties

Maps控件属性

PropertyTypeDescription
Layers
LayerCollectionCollection of ShapeFileLayers
MapBackgroundBrush
BrushBackground color of the map
MapItemsShape
MapItemShapesShape of map items (Circle, Diamond, etc.)
ZoomFactor
floatZoom level factor
ZoomLevel
intZoom level multiplier
SelectedMapShapes
CollectionCurrently selected shapes
属性类型描述
Layers
LayerCollectionShapeFileLayer集合
MapBackgroundBrush
Brush地图背景色
MapItemsShape
MapItemShapes地图项形状(圆形、菱形等)
ZoomFactor
float缩放等级系数
ZoomLevel
int缩放等级乘数
SelectedMapShapes
Collection当前选中的形状

ShapeFileLayer Properties

ShapeFileLayer属性

PropertyTypeDescription
Uri
stringPath to shape file (.shp)
ItemSource
objectData source for binding
ShapeIDPath
stringProperty name in data model
ShapeIDTableField
stringColumn name in .dbf file
ShowToolTip
boolEnable/disable tooltips
EnableSelection
boolEnable/disable selection
SelectionMode
SelectionModesSingle or Multiple selection
ShowLegend
boolShow/hide legend
LayoutType
LayoutTypeDefault or Tile layout
SubShapeFileLayers
CollectionAdditional shape layers
属性类型描述
Uri
stringshape文件(.shp)路径
ItemSource
object绑定数据源
ShapeIDPath
string数据模型中的属性名
ShapeIDTableField
string.dbf文件中的列名
ShowToolTip
bool启用/禁用提示框
EnableSelection
bool启用/禁用选中功能
SelectionMode
SelectionModes单选或多选
ShowLegend
bool显示/隐藏图例
LayoutType
LayoutType默认或瓦片布局
SubShapeFileLayers
Collection附加shape图层

ShapeSetting Properties

ShapeSetting属性

PropertyTypeDescription
ShapeFill
string/ColorFill color for shapes
ShapeStroke
string/ColorStroke color for shapes
ShapeStrokeThickness
doubleBorder thickness
ShapeValuePath
stringProperty for value binding
ShapeColorValuePath
stringProperty for color mapping
SelectedShapeColor
ColorColor for selected shapes
属性类型描述
ShapeFill
string/Color形状填充色
ShapeStroke
string/Color形状边框色
ShapeStrokeThickness
double边框粗细
ShapeValuePath
string值绑定属性
ShapeColorValuePath
string颜色映射属性
SelectedShapeColor
Color选中形状的颜色

BubbleSetting Properties

BubbleSetting属性

PropertyTypeDescription
AutoFillColors
boolAuto-generate bubble colors
MaxSize
doubleMaximum bubble size
MinSize
doubleMinimum bubble size
ValuePath
stringProperty for bubble size
ColorValuePath
stringProperty for bubble color
ColorMappings
CollectionRange-based color mappings
属性类型描述
AutoFillColors
bool自动生成气泡颜色
MaxSize
double气泡最大尺寸
MinSize
double气泡最小尺寸
ValuePath
string气泡大小对应属性
ColorValuePath
string气泡颜色对应属性
ColorMappings
Collection基于范围的颜色映射

Common Use Cases

常见用例

Use Case 1: Population Density Map

用例1:人口密度地图

Display world population by country with color-coded regions based on population ranges.
基于人口范围对区域进行颜色编码,展示世界各国人口数据。

Use Case 2: Sales Territory Map

用例2:销售区域地图

Visualize sales data by region with bubbles representing sales volume and colors indicating performance tiers.
按区域可视化销售数据,用气泡表示销售额大小,用颜色表示绩效等级。

Use Case 3: Election Results Map

用例3:选举结果地图

Show election results by state/province with color-coded winners and tooltips displaying vote counts.
按州/省展示选举结果,对获胜方进行颜色编码,通过提示框展示票数。

Use Case 4: Regional Analytics Dashboard

用例4:区域分析仪表盘

Create a dashboard with multiple map layers showing different data dimensions (demographics, economic indicators, etc.).
构建包含多个地图图层的仪表盘,展示不同数据维度(人口统计、经济指标等)。

Use Case 5: Location-Based Application

用例5:基于位置的应用

Build a desktop application that highlights specific locations with custom annotations and allows users to interact with map regions.
构建桌面应用,通过自定义注解高亮特定位置,允许用户与地图区域进行交互。

Troubleshooting

问题排查

Issue: Shape files not loading
  • Verify files are added as Embedded Resources
  • Check that Uri matches the shape file name exactly
  • Ensure .dbf file is included with .shp file
Issue: Data not binding to shapes
  • Confirm ShapeIDPath matches property in data model
  • Verify ShapeIDTableField matches column in .dbf file
  • Check that values match exactly (case-sensitive)
Issue: Colors not displaying correctly
  • Set
    AutoFillColors = false
    when using ColorMappings
  • Ensure color ranges cover all data values
  • Verify ColorValuePath points to correct property
Issue: Selection not working
  • Set
    EnableSelection = true
  • Configure
    SelectionMode
    (Single or Multiple)
  • Ensure shapes have bound data for selection
问题:Shape文件无法加载
  • 确认文件已设置为嵌入式资源
  • 检查Uri与shape文件名是否完全匹配
  • 确保.dbf文件与.shp文件一起导入
问题:数据无法绑定到形状
  • 确认ShapeIDPath与数据模型中的属性匹配
  • 确认ShapeIDTableField与.dbf文件中的列匹配
  • 检查值是否完全匹配(区分大小写)
问题:颜色显示异常
  • 使用ColorMappings时请设置
    AutoFillColors = false
  • 确保颜色范围覆盖所有数据值
  • 确认ColorValuePath指向正确的属性
问题:选中功能不生效
  • 设置
    EnableSelection = true
  • 配置
    SelectionMode
    (单选或多选)
  • 确保形状已绑定用于选中的数据