wpf-17984-controls-and-libraries-map-control-examples-gis-data-geocoding-how-to-create-a-custom-geocode-panel.md
Important
On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.
To obtain and display map data from Azure Maps, we implemented the following providers:
For information on how to migrate your app from Bing Maps to Azure Maps, see the following help topic: DevExpress Map Control for WPF: Migrate from Bing Maps to Azure Maps.
If you already have a Bing Maps for Enterprise license, you can keep using the current API. You must transition to the new API by June 30, 2025 (for free/basic licenses) or June 30, 2028 (for enterprise licenses). New licenses will no longer be available after June 30, 2025. Bing Maps will not work with our map controls without a license after that date.
To implement a custom geocode panel do the following.
Create an InformationLayer object and add it to the MapControl.Layers collection. Assign an instance of the BingGeocodeDataProvider class to the InformationLayer.DataProvider property. Specify the BingMapDataProviderBase.BingKey property of the provider.
Create a custom geocode panel. In this example, this panel includes two text edits (for the Latitude and Longitude ) and the Search button.
Call the BingGeocodeDataProvider.RequestLocationInformation method. In this example, this method is called in the Search button click event handler.
public GeoPoint GeocodeTarget { get; private set; }
public MainWindow() {
InitializeComponent();
GeocodeTarget = new GeoPoint();
DataContext = GeocodeTarget;
}
private void Button_Click(object sender, RoutedEventArgs e) {
geocodeProvider.RequestLocationInformation(GeocodeTarget, null);
}
<dxlc:LayoutControl Orientation="Vertical" Margin="2, 2, 2, 2">
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Latitude:">
<dxe:SpinEdit x:Name="teLatitude" MinValue="-90" MaxValue="90" Increment="0.1" Value="{Binding Latitude, Mode=TwoWay}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Longitude:">
<dxe:SpinEdit x:Name="teLongitude" MinValue="-180" MaxValue="180" Increment="0.1" Value="{Binding Longitude, Mode=TwoWay}"/>
</dxlc:LayoutItem>
<Button HorizontalAlignment="Center" VerticalAlignment="Top" Click="Button_Click" Content="Search"/>
</dxlc:LayoutGroup>
<dxlc:LayoutItem VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<dxm:MapControl>
<dxm:ImageTilesLayer>
<dxm:ImageTilesLayer.DataProvider>
<dxm:BingMapDataProvider BingKey="{Binding Source={StaticResource bingKey}}"/>
</dxm:ImageTilesLayer.DataProvider>
</dxm:ImageTilesLayer>
<dxm:InformationLayer>
<dxm:InformationLayer.DataProvider>
<dxm:BingGeocodeDataProvider x:Name="geocodeProvider"
BingKey="{Binding Source={StaticResource bingKey}}"/>
</dxm:InformationLayer.DataProvider>
</dxm:InformationLayer>
</dxm:MapControl>
</dxlc:LayoutItem>
</dxlc:LayoutControl>
Private privateGeocodeTarget As GeoPoint
Public Property GeocodeTarget() As GeoPoint
Get
Return privateGeocodeTarget
End Get
Private Set(ByVal value As GeoPoint)
privateGeocodeTarget = value
End Set
End Property
Public Sub New()
InitializeComponent()
GeocodeTarget = New GeoPoint()
DataContext = GeocodeTarget
End Sub
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
geocodeProvider.RequestLocationInformation(GeocodeTarget, Nothing)
End Sub
See Also
How to: Connect a Map Control to the Bing Geocode Service
How to: Get Information About a Geographical Point Using the Azure Geocode Service