wpf-devexpress-dot-xpf-dot-map-75c99201.md
The rectangular area bounding the region containing a search result.
Namespace : DevExpress.Xpf.Map
Assembly : DevExpress.Xpf.Map.v25.2.dll
NuGet Package : DevExpress.Wpf.Map
[NonCategorized]
public class SearchBoundingBox :
MapDependencyObject
<NonCategorized>
Public Class SearchBoundingBox
Inherits MapDependencyObject
The following members return SearchBoundingBox objects:
The SearchBoundingBox object is specified by the SearchBoundingBox.NorthLatitude, SearchBoundingBox.EastLongitude, SearchBoundingBox.SouthLatitude and SearchBoundingBox.WestLongitude values.
To send a route request, use the BingRouteDataProvider.CalculateRoute method. This method receives a list of RouteWaypoint objects as a parameter. Note that RouteWaypoint objects are created using the constructor that receives the waypoint description and a keyword that is used to search for a location on a map.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:CalculateRoutesByAddresses"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
x:Class="CalculateRoutesByAddresses.MainWindow"
Title="MainWindow" Height="360" Width="640"
dx:ThemeManager.ThemeName="Office2016White"
Loaded="OnLoaded">
<Window.Resources>
<sys:String x:Key="bingKey">Your Bing Key</sys:String>
</Window.Resources>
<Grid>
<dxm:MapControl x:Name="mapControl">
<dxm:ImageLayer>
<dxm:BingMapDataProvider BingKey="{Binding Source={StaticResource bingKey}}"/>
</dxm:ImageLayer>
<dxm:InformationLayer>
<dxm:BingRouteDataProvider x:Name="routeProvider"
RouteCalculated="OnRouteCalculated"
BingKey="{Binding Source={StaticResource bingKey}}"/>
</dxm:InformationLayer>
</dxm:MapControl>
<dx:WaitIndicator x:Name="waitIndicator"
DeferedVisibility="True"
Content="Calculating route...">
</dx:WaitIndicator>
</Grid>
</Window>
Imports DevExpress.Xpf.Map
Imports System.Collections.Generic
Imports System.Windows
Namespace CalculateRoutesByAddresses
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
routeProvider.CalculateRoute(New List(Of RouteWaypoint) From { _
New RouteWaypoint("New York", "Belmont Park, New York, USA"), _
New RouteWaypoint("Las Vegas", "Lorenzi Park, Las Vegas, USA") _
})
End Sub
Private Sub OnRouteCalculated(ByVal sender As Object, ByVal e As BingRouteCalculatedEventArgs)
Dim box As SearchBoundingBox = e.CalculationResult.RouteResults(0).BoundingBox
Dim topLeft As GeoPoint = New GeoPoint With {.Latitude = box.NorthLatitude, .Longitude = box.WestLongitude}
Dim bottomRight As GeoPoint = New GeoPoint With {.Latitude = box.SouthLatitude, .Longitude = box.EastLongitude}
mapControl.ZoomToRegion(topLeft, bottomRight, 0.4)
waitIndicator.DeferedVisibility = False
End Sub
End Class
End Namespace
using DevExpress.Xpf.Map;
using System.Collections.Generic;
using System.Windows;
namespace CalculateRoutesByAddresses {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void OnLoaded(object sender, RoutedEventArgs e) {
routeProvider.CalculateRoute(new List<RouteWaypoint> {
new RouteWaypoint("New York", "Belmont Park, New York, USA"),
new RouteWaypoint("Las Vegas", "Lorenzi Park, Las Vegas, USA")
});
}
private void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e) {
SearchBoundingBox box = e.CalculationResult.RouteResults[0].BoundingBox;
GeoPoint topLeft = new GeoPoint {
Latitude = box.NorthLatitude,
Longitude = box.WestLongitude
};
GeoPoint bottomRight = new GeoPoint {
Latitude = box.SouthLatitude,
Longitude = box.EastLongitude
};
mapControl.ZoomToRegion(topLeft, bottomRight, 0.4);
waitIndicator.DeferedVisibility = false;
}
}
}
Object DispatcherObject DependencyObject Freezable MapDependencyObject SearchBoundingBox
See Also