UsingBingMaps.Helpers.RouteCalculator.CalculateAsync C# (CSharp) Method

CalculateAsync() public method

public CalculateAsync ( ) : void
return void
        public void CalculateAsync()
        {
            if (from_address == true)
            {
                // Geocode locations in parallel.
                var results = new GeocodeResult[2];

                // To location.
                var state1 = new RoutingState(results, 1, _to);
                GeocodeAddress(_to, state1);

                // From location.
                var state0 = new RoutingState(results, 0, _from);
                GeocodeAddress(_from, state0);
            }
        }
        #endregion

Usage Example

        private void CalculateRouteByLocation(Location from, Location to)
        {
            Debug.WriteLine("CalculateRouteByLocation");
                var routeCalculator = new RouteCalculator(
                    CredentialsProvider,
                    to, from,
                    Dispatcher,
                    result =>
                    {
                        // Clear the route collection to have only one route at a time.
                        Routes.Clear();

                        // Clear previous route related itineraries.
                        Settings.Itinerary= new ObservableCollection<ItineraryItem>();

                        // Create a new route based on route calculator result,
                        // and add the new route to the route collection.
                        var routeModel = new RouteModel(result.Result.RoutePath.Points);
                        Routes.Add(routeModel);

                        // Add new route itineraries to the itineraries collection.
                        foreach (var itineraryItem in result.Result.Legs[0].Itinerary)
                        {
                            Settings.Itinerary.Add(itineraryItem);
                        }

                        // Set the map to center on the new route.
                        var viewRect = LocationRect.CreateLocationRect(routeModel.Locations);
                        Map.SetView(viewRect);                        
                        //ShowDirectionsView();
                    });

                // Display an error message in case of fault.
                routeCalculator.Error += r => MessageBox.Show(r.Reason);

                // Start the route calculation asynchronously.
                routeCalculator.CalculateAsync();
        }
All Usage Examples Of UsingBingMaps.Helpers.RouteCalculator::CalculateAsync