How to: Create a Custom Geocode Panel
- 2 minutes to read
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:
- AzureMapDataProvider
- AzureSearchDataProvider
- AzureRouteDataProvider
- AzureGeocodeDataProvider
- AzureTrafficIncidentDataProvider
- AzureRouteIsochroneDataProvider
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>