Back to Devexpress

InformationLayer.Data Property

windowsforms-devexpress-dot-xtramap-dot-informationlayer-d6c3b044.md

latest5.7 KB
Original Source

InformationLayer.Data Property

Specifies the data storage for the information layer.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public MapItemStorage Data { get; }
vb
Public ReadOnly Property Data As MapItemStorage

Property Value

TypeDescription
MapItemStorage

A MapItemStorage object.

|

Example

To manually generate map items for received GIS data, do the following.

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

namespace WinForms_MapControl_InformationLayer {
    public partial class Form1 : Form {
        InformationLayer GeocodeLayer { get { return (InformationLayer)mapControl1.Layers["GeocodeLayer"]; } }
        BingGeocodeDataProvider GeocodeProvider { get { return (BingGeocodeDataProvider)GeocodeLayer.DataProvider; } }

        public Form1() {
            InitializeComponent();
            GeocodeProvider.LocationInformationReceived += GeocodeProvider_LocationInformationReceived;
        }

        void GeocodeProvider_LocationInformationReceived(object sender, LocationInformationReceivedEventArgs e) {
            if ((e.Cancelled) && (e.Result.ResultCode != RequestResultCode.Success)) return;

            GeocodeLayer.Data.Items.Clear();
            foreach (LocationInformation locationInformation in e.Result.Locations)
                GeocodeLayer.Data.Items.Add(new MapCallout() {
                    Location = locationInformation.Location,
                    Text = locationInformation.DisplayName
                });
        }
    }
}
csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForms_MapControl_InformationLayer {
    static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms

Namespace WinForms_MapControl_InformationLayer
    Friend NotInheritable Class Program

        Private Sub New()
        End Sub

        ''' <summary>
        ''' The main entry point for the application.
        ''' </summary>
        <STAThread> _
        Shared Sub Main()
            Application.EnableVisualStyles()
            Application.SetCompatibleTextRenderingDefault(False)
            Application.Run(New Form1())
        End Sub
    End Class
End Namespace
vb
Imports DevExpress.XtraMap
Imports System.Windows.Forms

Namespace WinForms_MapControl_InformationLayer
    Partial Public Class Form1
        Inherits Form

        Private ReadOnly Property GeocodeLayer() As InformationLayer
            Get
                Return CType(mapControl1.Layers("GeocodeLayer"), InformationLayer)
            End Get
        End Property
        Private ReadOnly Property GeocodeProvider() As BingGeocodeDataProvider
            Get
                Return CType(GeocodeLayer.DataProvider, BingGeocodeDataProvider)
            End Get
        End Property

        Public Sub New()
            InitializeComponent()
            AddHandler GeocodeProvider.LocationInformationReceived, AddressOf GeocodeProvider_LocationInformationReceived
        End Sub

        Private Sub GeocodeProvider_LocationInformationReceived(ByVal sender As Object, ByVal e As LocationInformationReceivedEventArgs)
            If (e.Cancelled) AndAlso (e.Result.ResultCode <> RequestResultCode.Success) Then
                Return
            End If

            GeocodeLayer.Data.Items.Clear()
            For Each locationInformation As LocationInformation In e.Result.Locations
                GeocodeLayer.Data.Items.Add(New MapCallout() With {.Location = locationInformation.Location, .Text = locationInformation.DisplayName})
            Next locationInformation
        End Sub
    End Class
End Namespace

See Also

InformationLayer Class

InformationLayer Members

DevExpress.XtraMap Namespace