Skip to main content
All docs
V25.1
  • AzureGeocodeDataProvider Class

    Allows you to obtain geo data from the Azure Maps Geocode service.

    Namespace: DevExpress.Xpf.Map

    Assembly: DevExpress.Xpf.Map.v25.1.dll

    NuGet Package: DevExpress.Wpf.Map

    Declaration

    public class AzureGeocodeDataProvider :
        AzureMapDataProviderBase,
        IMouseClickRequestSender

    Remarks

    The map control allows you to use the Azure Maps Search service to search for a full or partial address and return the longitude and latitude coordinates of the address. This process is called geocoding. The ability to geocode in a country/region depends on the availability of road data and the precision of the geocoding service. For more information about Azure Maps’ geocoding capabilities by country or region, see Geocoding coverage.

    The AzureGeocodeDataProvider implements the Azure Maps Geocode service. Assign this object to the InformationLayer.DataProvider property to enable the service and allow users to obtain information about a point on a map.

    Azure Maps services support JSON response formats. Install the System.Text.Json package in projects that target .NET Framework to parse the Azure server response and display information on a DevExpress Map control.

    Call the RequestLocationInformation method overloads to obtain information about the specified location.

    To get geocode results, handle the LocationInformationReceived event. The e.Result argument returns a GeocodeRequestResult descendant that stores geocode results.

    If you wish to specify the number of requested results displayed, use the MaxVisibleResultCount property.

    For more information on how to use geocoding services, refer to the following help topic: Geocode.

    Example

    The following example obtains the location information such as location address based on geo point coordinates:

    DevExpress MapControl for WPF - An address found using AzureGeocodeProvider based on a geo point

    <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:AzureGeocodeDataProvider x:Name="geocodeProvider" AzureKey="{StaticResource azureKey}"   
                                                LocationInformationReceived="geocodeProvider_LocationInformationReceived"
                                                MaxVisibleResultCount="1" 
                                                ProcessMouseEvents="False"
                                                GenerateLayerItems="False"/>
                </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) {
                geocodeProvider.RequestLocationInformation(new GeoPoint(40.730610, -73.935242));
            }
            // The following code shows the obtained location information in a pushpin tooltip:
            private void geocodeProvider_LocationInformationReceived(object sender, LocationInformationReceivedEventArgs e) {
                LocationInformation info = e.Result.Locations[0];
                MapPushpin mapPushpin = new MapPushpin { Location = info.Location };
                mapPushpin.ToolTipPattern = info.DisplayName;
                VectorLayer vectorLayer = new VectorLayer();
                MapItemStorage mapItemStorage = new MapItemStorage();
                mapItemStorage.Items.Add(mapPushpin);
                vectorLayer.Data = mapItemStorage;
                mapControl.Layers.Add(vectorLayer);
                mapControl.ZoomToFit(vectorLayer.Data.DisplayItems, 0.4);
            }
        }
    }
    
    See Also