Back to Devexpress

GeocodeRequestResult Class

windowsforms-devexpress-dot-xtramap-dcad3027.md

latest6.1 KB
Original Source

GeocodeRequestResult Class

Contains results of a request to a web service to obtain Geocode information about a specific location on a map.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public class GeocodeRequestResult :
    RequestResultBase
vb
Public Class GeocodeRequestResult
    Inherits RequestResultBase

The following members return GeocodeRequestResult objects:

Remarks

An object of this class is accessed using the LocationInformationReceivedEventArgs.Result property.

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

Inheritance

Object RequestResultBase GeocodeRequestResult

See Also

GeocodeRequestResult Members

DevExpress.XtraMap Namespace