コード例 #1
0
 private static void OnRouteResultChanged(Map map, BingServices.RouteResult oldValue, BingServices.RouteResult newValue)
 {
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: kkurys/TripPlanner
        private void GetRoutesFromService()
        {
            using (BingServices.RouteServiceClient client = new BingServices.RouteServiceClient("CustomBinding_IRouteService"))
            {
                int n           = 1;
                var credentials = new Credentials()
                {
                    ApplicationId = (App.Current.Resources["MyCredentials"] as ApplicationIdCredentialsProvider).ApplicationId
                };

                BingServices.RouteRequest request = new BingServices.RouteRequest();
                request.Credentials = credentials;
                request.Waypoints   = new ObservableCollection <Waypoint>();
                foreach (Individual i in Parameters.solutions)
                {
                    int waypointsAdded = 0;

                    request.Waypoints = new ObservableCollection <Waypoint>();
                    for (int x = 0; x < i.Count; x++)
                    {
                        if (x == 0 || x == i.path.Count - 1)
                        {
                            request.Waypoints.Add(
                                new Waypoint()
                            {
                                Location = new BingServices.Location()
                                {
                                    Latitude  = Hotel.ActiveHotel.Lat,
                                    Longitude = Hotel.ActiveHotel.Long
                                }
                            });
                            waypointsAdded++;
                        }
                        else
                        {
                            var _attraction = _attractions.Find(z => z.Id == i.path[x]);
                            request.Waypoints.Add(
                                new Waypoint()
                            {
                                Location = new BingServices.Location()
                                {
                                    Latitude  = _attraction.Lat,
                                    Longitude = _attraction.Long
                                }
                            });
                            waypointsAdded++;
                        }
                        if (i.Count - x < 3 && waypointsAdded + i.Count - x < 2 || waypointsAdded == 25 || x == i.path.Count - 1)
                        {
                            request.Options = new BingServices.RouteOptions();
                            request.Options.RoutePathType = BingServices.RoutePathType.Points;
                            if (request.Waypoints.Count == 1)
                            {
                                request.Waypoints.Add(
                                    new Waypoint()
                                {
                                    Location = new BingServices.Location()
                                    {
                                        Latitude  = Hotel.ActiveHotel.Lat,
                                        Longitude = Hotel.ActiveHotel.Long
                                    }
                                });
                            }
                            RouteResult = client.CalculateRoute(request).Result;
                            AddRoutePart(RouteResult, n);
                            request.Waypoints = new ObservableCollection <Waypoint>();
                            waypointsAdded    = 0;
                        }
                    }
                    n++;
                }
            }
        }
コード例 #3
0
 public static void SetRouteResult(DependencyObject target, BingServices.RouteResult value)
 {
     target.SetValue(RouteResultProperty, value);
 }