Back to Devexpress

How to: Connect a Map Control to the Bing Geocode Service

windowsforms-16617-controls-and-libraries-map-control-examples-gis-data-geocoding-how-to-connect-a-map-control-to-the-bing-geocode-service.md

latest2.1 KB
Original Source

How to: Connect a Map Control to the Bing Geocode Service

  • Nov 13, 2018

This example demonstrates how to provide the capability for end-users to search an address associated with a specified location on a map and get detailed information about this place in the pushpin’s tooltip, utilizing the Bing Geocode web service. Do this as follows:.

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

namespace GeocodeProvider {
    public partial class Form1 : Form {
        const string bingKey = "YOUR BING KEY HERE";

        InformationLayer GeocodeLayer {
            get {
                return (InformationLayer)mapControl1.Layers["GeocodeLayer"];
            }
        }

        public Form1() {
            InitializeComponent();

            GeocodeLayer.DataProvider = new BingGeocodeDataProvider() {
                BingKey = bingKey,
                MaxVisibleResultCount = 1
            };
        }
    }

}
vb
Imports DevExpress.XtraMap
Imports System.Windows.Forms

Namespace GeocodeProvider
    Partial Public Class Form1
        Inherits Form

        Private Const bingKey As String = "YOUR BING KEY HERE"

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

        Public Sub New()
            InitializeComponent()

            GeocodeLayer.DataProvider = New BingGeocodeDataProvider() With {.BingKey = bingKey, .MaxVisibleResultCount = 1}
        End Sub
    End Class

End Namespace