AzureSearchDataProvider.SearchCompleted Event
In This Article
Occurs when a search operation has been completed.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.2.dll
NuGet Package: DevExpress.Win.Map
#Declaration
public event AzureSearchCompletedEventHandler SearchCompleted
#Event Data
The SearchCompleted event's data class is AzureSearchCompletedEventArgs. 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 Async |
Error |
Gets a value indicating which error occurred during an asynchronous operation.
Inherited from Async |
Request |
Returns the result of the search request.
Inherited from Search |
User |
Gets the unique identifier for the asynchronous task.
Inherited from Async |
The event data class exposes the following methods:
Method | Description |
---|---|
Raise |
Raises a user-supplied exception if an asynchronous operation failed.
Inherited from Async |
#Remarks
To obtain search results for received GIS data, do the following:
- Handle the
SearchCompleted
event. - In the event handler, read the e.RequestResult.SearchResults to obtain an array of LocationInformation objects.
The following image illustrates the result:
using DevExpress.XtraMap;
// ...
const string azureKey = "your key";
// ...
AzureSearchDataProvider azureSearchProvider = new AzureSearchDataProvider() {
AzureKey = azureKey,
};
azureSearchProvider.Search("Redmond 15127 NE 24th St");
azureSearchProvider.SearchCompleted += new AzureSearchCompletedEventHandler(OnSearchCompleted);
void OnSearchCompleted(object sender, AzureSearchCompletedEventArgs e) {
if (e.Cancelled) return;
if (e.RequestResult.ResultCode != RequestResultCode.Success) {
MessageBox.Show("The Azure Search service does not work for this location.");
return;
}
StringBuilder resultList = new StringBuilder("");
int resCounter = 1;
foreach (LocationInformation resultInfo in e.RequestResult.SearchResults) {
resultList.Append(String.Format("Result {0}: \r\n", resCounter));
resultList.Append(String.Format("Address: {0}\r\n", resultInfo.Address.FormattedAddress));
resultList.Append(String.Format("Geographic coordinates: {0}\r\n", resultInfo.Location));
resultList.Append(String.Format("______________________________\r\n"));
resCounter++;
}
MessageBox.Show(resultList.ToString());
}
InformationLayer informationLayer = new InformationLayer();
informationLayer.DataProvider = azureSearchProvider;
map.Layers.Add(informationLayer);
See Also