Back to Devexpress

SearchBoundingBox Class

windowsforms-devexpress-dot-xtramap-8b932148.md

latest5.6 KB
Original Source

SearchBoundingBox Class

The rectangular area bounding the region containing a search result.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public class SearchBoundingBox
vb
Public Class SearchBoundingBox

The following members return SearchBoundingBox objects:

Remarks

The SearchBoundingBox object is specified by the SearchBoundingBox.NorthLatitude, SearchBoundingBox.EastLongitude, SearchBoundingBox.SouthLatitude and SearchBoundingBox.WestLongitude values.

Example

This example demonstrates how to zoom a map to the calculated route.

To do this, handle the BingRouteDataProvider.RouteCalculated event. In the event handler, using the BingRouteResult.BoundingBox property, get the top-left corner (using the SearchBoundingBox.NorthLatitude and SearchBoundingBox.WestLongitude properties) and right-bottom corner (using the SearchBoundingBox.SouthLatitude and SearchBoundingBox.EastLongitude properties) of the required region. Then, using the MapControl.ZoomToRegion method, zoom the map to the required rectangle specified by the corners.

csharp
using DevExpress.XtraMap;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ZoomToFitOnRouteCalculated {
    public partial class Form1 : Form {
        InformationLayer Layer { get { return (InformationLayer)mapControl.Layers[1]; } }
        BingRouteDataProvider Provider { get { return (BingRouteDataProvider)Layer.DataProvider; } }
        public Form1() {
            InitializeComponent();
        }
        void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e) {
            SearchBoundingBox bBox = e.CalculationResult.RouteResults[0].BoundingBox;
            mapControl.ZoomToRegion(new GeoPoint(bBox.NorthLatitude, bBox.WestLongitude), new GeoPoint(bBox.SouthLatitude, bBox.EastLongitude), 0.4);
            splashScreenManager.CloseWaitForm();
        }
        private void Form1_Load(object sender, System.EventArgs e) {
            Provider.RouteCalculated += OnRouteCalculated;
            Provider.CalculateRoute(new List<RouteWaypoint> {
                new RouteWaypoint("New York", new GeoPoint(41.145556, -73.995)),
                new RouteWaypoint("Oklahoma", new GeoPoint(36.131389, -95.937222)),
                new RouteWaypoint("Las Vegas", new GeoPoint(36.175, -115.136389))
            });
            splashScreenManager.ShowWaitForm();
        }
    }
}
vb
Imports DevExpress.XtraMap
Imports System.Collections.Generic
Imports System.Windows.Forms

Namespace ZoomToFitOnRouteCalculated
    Partial Public Class Form1
        Inherits Form

        Private ReadOnly Property Layer() As InformationLayer
            Get
                Return CType(mapControl.Layers(1), InformationLayer)
            End Get
        End Property
        Private ReadOnly Property Provider() As BingRouteDataProvider
            Get
                Return CType(Layer.DataProvider, BingRouteDataProvider)
            End Get
        End Property
        Public Sub New()
            InitializeComponent()
        End Sub
        Private Sub OnRouteCalculated(ByVal sender As Object, ByVal e As BingRouteCalculatedEventArgs)
            Dim bBox As SearchBoundingBox = e.CalculationResult.RouteResults(0).BoundingBox
            mapControl.ZoomToRegion(New GeoPoint(bBox.NorthLatitude, bBox.WestLongitude), New GeoPoint(bBox.SouthLatitude, bBox.EastLongitude), 0.4)
            splashScreenManager.CloseWaitForm()
        End Sub
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            AddHandler Provider.RouteCalculated, AddressOf OnRouteCalculated
            Provider.CalculateRoute(New List(Of RouteWaypoint) From { _
                New RouteWaypoint("New York", New GeoPoint(41.145556, -73.995)), _
                New RouteWaypoint("Oklahoma", New GeoPoint(36.131389, -95.937222)), _
                New RouteWaypoint("Las Vegas", New GeoPoint(36.175, -115.136389)) _
            })
            splashScreenManager.ShowWaitForm()
        End Sub
    End Class
End Namespace

Inheritance

Object SearchBoundingBox

See Also

SearchBoundingBox Members

DevExpress.XtraMap Namespace