Skip to main content
All docs
V24.1

BingRouteIsochroneDataProvider.IsochroneCalculated Event

Occurs after an isochrone is calculated.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.Map

Declaration

public event BingRouteIsochroneCalculatedEventHandler IsochroneCalculated

Event Data

The IsochroneCalculated event's data class is BingRouteIsochroneCalculatedEventArgs. The following properties provide information specific to this event:

Property Description
CalculationResult Returns the result of an isochrone calculation (isoline polygon points and origin waypoint coordinates).
Cancelled Gets a value indicating whether an asynchronous operation has been canceled. Inherited from AsyncCompletedEventArgs.
Error Gets a value indicating which error occurred during an asynchronous operation. Inherited from AsyncCompletedEventArgs.
UserState Gets the unique identifier for the asynchronous task. Inherited from AsyncCompletedEventArgs.

The event data class exposes the following methods:

Method Description
RaiseExceptionIfNecessary() Raises a user-supplied exception if an asynchronous operation failed. Inherited from AsyncCompletedEventArgs.

Remarks

The following code plots a polygon that shows an area accessible from the specified point:

An isochrone map

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:IsochroneMap"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="IsochroneMap.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
    <Grid>
        <dxm:MapControl x:Name="mapControl">
            <dxm:ImageLayer>
                <dxm:BingMapDataProvider BingKey="Insert your Bing key." 
                                            Kind="RoadLight" />
            </dxm:ImageLayer>
            <dxm:InformationLayer x:Name="infoLayer">
                <dxm:BingRouteIsochroneDataProvider x:Name="isochroneProvider" 
                                                    BingKey="Insert your Bing key."
                                                    GenerateLayerItems="False"
                                                    IsochroneCalculated="OnIsochroneCalculated">
                    <dxm:BingRouteIsochroneDataProvider.IsochroneOptions>
                        <dxm:BingRouteIsochroneOptions Mode="Driving" 
                                                    DistanceUnit="Kilometer"/>
                    </dxm:BingRouteIsochroneDataProvider.IsochroneOptions>
                </dxm:BingRouteIsochroneDataProvider>
            </dxm:InformationLayer>
        </dxm:MapControl>
    </Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Windows;
using System.Windows.Media;

namespace IsochroneMap {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            GeoPoint origin = new GeoPoint(42.3589935302734, -71.0586318969727);
            isochroneProvider.CalculateIsochroneByDistance(new RouteWaypoint("Origin", origin), 10);
        }

        private void OnIsochroneCalculated(object sender, BingRouteIsochroneCalculatedEventArgs e) {
            foreach (var polygon in e.CalculationResult.IsochroneResult.Polygons) {
                MapPolyline item = new MapPolyline();
                foreach (var points in polygon.Coordinates)
                    item.Points.Add(points);
                item.StrokeStyle = new StrokeStyle { Thickness = 4 };
                item.Stroke = Brushes.Red;

                MapPushpin pushpin = new MapPushpin { Location = e.CalculationResult.IsochroneResult.Origin, Brush = Brushes.Red };

                VectorLayer vectorLayer = new VectorLayer();
                mapControl.Layers.Add(vectorLayer);
                MapItemStorage storage = new MapItemStorage();
                vectorLayer.Data = storage;
                storage.Items.Add(item);
                storage.Items.Add(pushpin);
            }
            mapControl.ZoomToFitLayerItems();
        }
    }
}
See Also