Back to Devexpress

HeatmapDataSourceAdapter.Mappings Property

windowsforms-devexpress-dot-xtramap-dot-heatmapdatasourceadapter.md

latest6.6 KB
Original Source

HeatmapDataSourceAdapter.Mappings Property

Contains information on how data for heatmap points should be obtained from a data source.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public HeatmapPointMappingInfo Mappings { get; }
vb
Public ReadOnly Property Mappings As HeatmapPointMappingInfo

Property Value

TypeDescription
HeatmapPointMappingInfo

Provides information on the mapping of the heatmap point properties to the data fields.

|

Example

This example shows how to create a heatmap layer for the Map Control.

csharp
using DevExpress.XtraMap;
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace HeatMapSample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {

            ImageLayer bingLayer = new ImageLayer();
            bingLayer.DataProvider = new BingMapDataProvider { BingKey = "Your Bing Maps key here." };
            mapControl1.Layers.Add(bingLayer);

            ChoroplethColorizer colorizer = new ChoroplethColorizer();
            colorizer.RangeStops.AddRange(new double[] { 0.1, 0.2, 0.7, 1 });
            colorizer.ColorItems.Add(new ColorizerColorItem(Color.FromArgb(50, 128, 255, 0)));
            colorizer.ColorItems.Add(new ColorizerColorItem(Color.FromArgb(255, 255, 255, 0)));
            colorizer.ColorItems.Add(new ColorizerColorItem(Color.FromArgb(255, 234, 72, 58)));
            colorizer.ColorItems.Add(new ColorizerColorItem(Color.FromArgb(255, 162, 36, 25)));
            colorizer.ApproximateColors = true;

            HeatmapDataSourceAdapter adapter = new HeatmapDataSourceAdapter();
            adapter.Mappings.XCoordinate = "glon"; // The data source field name that provides x-coordinates.
            adapter.Mappings.YCoordinate = "glat"; // The data source field name that provides y-coordinates.
            adapter.DataSource = LoadData("../../Data/Earthquakes.xml", "Row");

            HeatmapProvider provider = new HeatmapProvider();
            provider.PointSource = adapter;
            provider.Algorithm = new HeatmapDensityBasedAlgorithm { PointRadius = 8 };
            provider.Colorizer = colorizer;

            ImageLayer heatmapLayer = new ImageLayer();
            heatmapLayer.DataProvider = provider;
            mapControl1.Layers.Add(heatmapLayer);

            ColorScaleLegend legend = new ColorScaleLegend();
            legend.Header = "Seismic Density";
            legend.EnableGradientScale = true;
            legend.Layer = heatmapLayer;
            legend.HeaderStyle.Font = new Font("Tahoma", 12F);
            mapControl1.Legends.Add(legend);
        }
        DataTable LoadData(string filePath, string tableName) {
            DataSet xmlDataSet = new DataSet("XML DataSet");
            xmlDataSet.ReadXml(filePath);
            return xmlDataSet.Tables[tableName];
        }
    }
}
vb
Imports DevExpress.XtraMap
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms

Namespace HeatMapSample

    Public Class Form1
        Inherits Form

        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            Dim bingLayer As ImageLayer = New ImageLayer
            bingLayer.DataProvider = New BingMapDataProvider() {BingKey=Your Bing Maps key here.}
            mapControl1.Layers.Add(bingLayer)

            Dim colorizer As ChoroplethColorizer = New ChoroplethColorizer
            colorizer.RangeStops.AddRange(New Double() {0.1, 0.2, 0.7, 1})
            colorizer.ColorItems.Add(New ColorizerColorItem(Color.FromArgb(50, 128, 255, 0)))
            colorizer.ColorItems.Add(New ColorizerColorItem(Color.FromArgb(255, 255, 255, 0)))
            colorizer.ColorItems.Add(New ColorizerColorItem(Color.FromArgb(255, 234, 72, 58)))
            colorizer.ColorItems.Add(New ColorizerColorItem(Color.FromArgb(255, 162, 36, 25)))
            colorizer.ApproximateColors = true

            Dim adapter As HeatmapDataSourceAdapter = New HeatmapDataSourceAdapter
            adapter.Mappings.XCoordinate = "glon" ' The data source field name that provides x-coordinates.
            adapter.Mappings.YCoordinate = "glat" ' The data source field name that provides y-coordinates.
            adapter.DataSource = Me.LoadData("../../Data/Earthquakes.xml", "Row")

            Dim provider As HeatmapProvider = New HeatmapProvider
            provider.PointSource = adapter
            provider.Algorithm = New HeatmapDensityBasedAlgorithm() {PointRadius=8}
            provider.Colorizer = colorizer

            Dim heatmapLayer As ImageLayer = New ImageLayer
            heatmapLayer.DataProvider = provider
            mapControl1.Layers.Add(heatmapLayer)

            Dim legend As ColorScaleLegend = New ColorScaleLegend
            legend.Header = "Seismic Density"
            legend.EnableGradientScale = true
            legend.Layer = heatmapLayer
            legend.HeaderStyle.Font = New Font("Tahoma", 12!)
            mapControl1.Legends.Add(legend)
        End Sub

        Private Function LoadData(ByVal filePath As String, ByVal tableName As String) As DataTable
            Dim xmlDataSet As DataSet = New DataSet("XML DataSet")
            xmlDataSet.ReadXml(filePath)
            Return xmlDataSet.Tables(tableName)
        End Function
    End Class
End Namespace

See Also

HeatmapDataSourceAdapter Class

HeatmapDataSourceAdapter Members

DevExpress.XtraMap Namespace