Back to Devexpress

BingSearchDataProvider Class

windowsforms-devexpress-dot-xtramap-4ac61243.md

latest7.1 KB
Original Source

BingSearchDataProvider Class

OBSOLETE

This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms

The class that is used to send requests to the Bing Maps Search service.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
[Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms")]
[PreferableMember("BingSearchDataProvider", "", "")]
public class BingSearchDataProvider :
    BingMapDataProviderBase,
    ISearchPanelRequestSender
vb
<Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms")>
<PreferableMember("BingSearchDataProvider", "", "")>
Public Class BingSearchDataProvider
    Inherits BingMapDataProviderBase
    Implements ISearchPanelRequestSender

Remarks

The Bing Search Data provider is represented by the BingSearchDataProvider object that can be accessed via the InformationLayer.DataProvider property.

Important

On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.

To obtain and display map data from Azure Maps, we implemented the following providers:

For information on how to migrate your app from Bing Maps to Azure Maps, see the following help topic: Migrate from Bing Maps to Azure Maps Providers.

If you already have a Bing Maps for Enterprise license, you can keep using the current API. You must transition to the new API by June 30, 2025 (for free/basic licenses) or June 30, 2028 (for enterprise licenses). New licenses will no longer be available after June 30, 2025. Bing Maps will not work with our map controls without a license after that date.

To get access to the search options of the Bing Search Data provider, use the BingSearchDataProvider.SearchOptions property.

If you wish to see the search results in a search panel, use the MapSearchPanelOptions.Visible property.

The Search(string keyword) method is used to find a particular location by its name.

The Search(BingAddress address) method is used to find places by their addresses.

The results will be returned using the SearchRequestResult.SearchResults property of the BingSearchDataProvider.SearchCompleted event arguments’ SearchCompletedEventArgs.RequestResult property.

Example

This example demonstrates how to allow users to search for a specific place on a map using the Search panel.

To enable searching in the map control, do the following.

  • Create an InformationLayer and add it to the map.
  • Create an instance of the BingSearchDataProvider and assign it to the InformationLayer.DataProvider property.
  • Specify the Bing Maps key using the BingMapDataProvider.BingKey property.

The Search panel appears automatically (since the MapSearchPanelOptions.Visible property value is true by default).

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

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

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

        public Form1() {
            InitializeComponent();

            BingSearchDataProvider searchProvider = new BingSearchDataProvider() { 
                BingKey = bingKey 
            };

            searchProvider.SearchOptions.ResultsCount = 5;

            SearchLayer.DataProvider = searchProvider;
        }      
    }
}
vb
Imports DevExpress.XtraMap
Imports System.Windows.Forms

Namespace ConnectBingSearchProvider
    Partial Public Class Form1
        Inherits Form

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

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

        Public Sub New()
            InitializeComponent()

            Dim searchProvider As New BingSearchDataProvider() With {.BingKey = bingKey}

            searchProvider.SearchOptions.ResultsCount = 5

            SearchLayer.DataProvider = searchProvider
        End Sub
    End Class
End Namespace

Implements

ISupportWebRequest

ISearchPanelRequestSender

Inheritance

Object InformationDataProviderBase WebInformationDataProvider BingMapDataProviderBase BingSearchDataProvider

See Also

BingSearchDataProvider Members

GIS Data

DevExpress.XtraMap Namespace