BingSearchDataProvider.SearchCompleted Event
Occurs when a search operation has been completed.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.2.dll
Declaration
Event Data
The SearchCompleted event's data class is BingSearchCompletedEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancelled | Gets a value indicating whether an asynchronous operation has been canceled. Inherited from AsyncCompletedEventArgs. |
Error | Gets a value indicating which error occurred during an asynchronous operation. Inherited from AsyncCompletedEventArgs. |
RequestResult | Returns the result of the search request. Inherited from SearchCompletedEventArgs. |
UserState | Gets the unique identifier for the asynchronous task. Inherited from AsyncCompletedEventArgs. |
The event data class exposes the following methods:
Method | Description |
---|---|
RaiseExceptionIfNecessary() | Raises a user-supplied exception if an asynchronous operation failed. Inherited from AsyncCompletedEventArgs. |
Example
To manually generate map items for received GIS data, do the following.
- Set the InformationDataProviderBase.GenerateLayerItems property to false.
- Handle the Geocode data received event of the Bing geocode data provider (
BingSearchDataProvider.SearchCompleted
). - In the event handler, implement map item generation based on information stored in the SearchRequestResult.SearchResults array of LocationInformation objects.
using DevExpress.XtraEditors;
using DevExpress.XtraMap;
using System;
using System.Text;
namespace MapControl_SearchProcessing {
public partial class Form1 : XtraForm {
string BingKey { get { return "YourBingKey"; } }
public Form1() {
InitializeComponent();
SearchProvider.SearchCompleted += OnSearchCompleted;
SearchLayer.DataRequestCompleted += OnDataRequestCompleted;
BingMapDataProvider.BingKey = BingKey;
SearchProvider.BingKey = BingKey;
}
private void btnSearch_Click(object sender, EventArgs e) {
SearchProvider.Search(teKeyword.Text);
}
#region #SearchResultProcessing
void OnSearchCompleted(object sender, BingSearchCompletedEventArgs e) {
if(e.Cancelled) return;
if(e.RequestResult.ResultCode != RequestResultCode.Success) {
meResult.Text = "The Bing Search service does not work for this location.";
return;
}
StringBuilder resultList = new StringBuilder("");
int resCounter = 1;
foreach(BingLocationInformation resultInfo in e.RequestResult.SearchResults) {
resultList.Append(String.Format("Result {0}: \r\n", resCounter));
resultList.Append(String.Format("Name: {0}\r\n", resultInfo.DisplayName));
resultList.Append(String.Format("Address: {0}\r\n", resultInfo.Address.FormattedAddress));
resultList.Append(String.Format("Confidence level: {0}\r\n", resultInfo.Confidence));
resultList.Append(String.Format("Geographic coordinates: {0}\r\n", resultInfo.Location));
resultList.Append(String.Format("Match code: {0}\r\n", resultInfo.MatchCode));
resultList.Append(String.Format("______________________________\r\n"));
resCounter++;
}
meResult.Text = resultList.ToString();
}
#endregion #SearchResultProcessing
void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
mapControl.ZoomToFitLayerItems(0.4);
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SearchCompleted event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.