wpf-devexpress-dot-xpf-dot-map-6af44e20.md
Allows you to obtain geo data from the Azure Maps Search service.
Namespace : DevExpress.Xpf.Map
Assembly : DevExpress.Xpf.Map.v25.2.dll
NuGet Package : DevExpress.Wpf.Map
public class AzureSearchDataProvider :
AzureMapDataProviderBase,
ISearchPanelRequestSender
Public Class AzureSearchDataProvider
Inherits AzureMapDataProviderBase
Implements ISearchPanelRequestSender
AzureSearchDataProvider allows you to use the Azure Maps Search service. Assign such an object to the InformationLayer.DataProvider property to display the search panel and allow users to search for a specific place on a map. To hide the search panel, set the MapControl.ShowSearchPanel property to false.
Call the AzureSearchDataProvider.Search method to search for locations that correspond to the specified attributes. The maxResults parameter of the Search method overloads allows you to specify the number of results that can be obtained by a search request.
To get search results, handle the SearchCompleted event. The SearchCompletedEventArgs.RequestResult returns a SearchRequestResult object that stores search results.
For more information on how to use search map services in the Map Control, refer to the following help topic: Search.
The following example calls the AzureSearchDataProvider.Search method to search for a location by a text search query:
<Window xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
...>
<Window.Resources>
<sys:String x:Key="azureKey">
Your AzureMaps key here.
</sys:String>
</Window.Resources>
<Grid>
<dxm:MapControl Loaded="MapControl_Loaded" x:Name="mapControl" ToolTipEnabled="True" ShowSearchPanel="False">
<dxm:ImageLayer>
<dxm:AzureMapDataProvider AzureKey="{StaticResource azureKey}" Tileset="BaseRoad"/>
</dxm:ImageLayer>
<dxm:InformationLayer x:Name="infoLayer">
<dxm:AzureSearchDataProvider x:Name="searchProvider" AzureKey="{StaticResource azureKey}"
LayerItemsGenerating="OnLayerItemsGenerating"/>
</dxm:InformationLayer>
</dxm:MapControl>
</Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Windows;
namespace WpfMapExample {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void MapControl_Loaded(object sender, RoutedEventArgs e) {
searchProvider.Search("Av. Gustave Eiffel", maxResults: 5);
}
private void OnLayerItemsGenerating(object sender, LayerItemsGeneratingEventArgs args) {
mapControl.ZoomToFit(args.Items, 0.8);
}
}
}
Imports DevExpress.Xpf.Map
Imports System.Windows
Namespace WpfMapExample
Public Partial Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub MapControl_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
searchProvider.Search("Av. Gustave Eiffel", maxResults:=5)
End Sub
Private Sub OnLayerItemsGenerating(ByVal sender As Object, ByVal args As LayerItemsGeneratingEventArgs)
mapControl.ZoomToFit(args.Items, 0.8)
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the AzureSearchDataProvider class.
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.
wpf-map-process-search-with-a-custom-search-panel/CS/MapControl_SearchPanel/MainWindow.xaml#L35
<dxm:InformationLayer.DataProvider>
<dxm:AzureSearchDataProvider x:Name="searchProvider"
AzureKey="{Binding Source={StaticResource azureKey}}"
wpf-map-search-with-azure-map-search-service/CS/DXMapExample/MainWindow.xaml#L30
<!--region #SearchCompleted-->
<dxm:AzureSearchDataProvider x:Name="searchDataProvider"
AzureKey="{Binding Source={StaticResource azureMapsKey}}"
Object DispatcherObject DependencyObject Freezable MapDependencyObject InformationDataProviderBase WebInformationDataProvider<DevExpress.Map.Native.JsonProvidedEventArgs> AzureMapDataProviderBase AzureSearchDataProvider
See Also