Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Collapse]Map Control
   [Expand]Getting Started
    Layers
   [Expand]Coordinate Systems
   [Expand]Map Image Data
   [Collapse]GIS Data
     Search
     Geocode
     Routing
     Elevation
   [Expand]Vector Data
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]End-User Features
   [Expand]Product Information
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Search

This document explains how to provide a Map control with the capability to search for a location on a map and get additional search results.

The document consists of the following sections.

Expanded Overview

The Map control supports the Microsoft Bing Search and OpenStreetMap Search services, allowing you to embed search functionality in your application. When this feature is enabled, you can type search criteria in the Search Panel (or use a custom UI), implement a request, and view the results in both the map and the search panel.

The search functionality in the map control is performed by the Bing Search data provider. This provider is represented by the BingSearchDataProvider or OsmSearchDataProvider object. The section below explains how to use a Search Data Provider in the map control.

Expanded Enabling Search

To enable search in the Map control, do the following.

The code snippet below shows how this can be done.

In addition, you can customize the search result count.

After the search feature is enabled, the Map control's built-in search panel is automatically invoked (the MapControl.ShowSearchPanel is set to true by default). To learn more about the built-in Search panel, see the Search Panel topic.

Expanded Using a Custom UI

The Map control provides search functionality for additional parameters like a country region or a postal code. Using this approach, you can build a custom search panel to get additional search results from the Search services.

Note

The built-in Search panel is not used for this approach, so make sure that the MapControl.ShowSearchPanel property is set to false.

To start searching for a location, call the BingSearchDataProvider.Search or OsmSearchDataProvider.Search method.

For instance, you have a UI that consists of a text box named "tbKeywords" and a button named "btnSearch". To start a search, click the Search button. This calls the following overload of the Search method.

Expanded Search Results

To get the results for the executed search, handle the BingSearchDataProvider.SearchCompleted or OsmSearchDataProvider.SearchCompleted event.

Search results are held by the RequestResultBase object's SearchRequestResult descendant within the BingSearchCompletedEventArgs of the SearchCompleted event handler.

The results contain a display name, an address, and the geographic coordinates (latitude and longitude) associated with the search location.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T188838.

The search results for Keywords ("New York") are shown in the image below.

Expanded See Also

How would you rate this topic?​​​​​​​