Exemplo n.º 1
0
 private RouteService.Waypoint GeoCodeResultToWaypoint(GeocodeService.GeocodeResult result)
 {
     RouteService.Waypoint waypoint = new RouteService.Waypoint();
     waypoint.Description        = result.DisplayName;
     waypoint.Location           = new Location();
     waypoint.Location.Latitude  = result.Locations[0].Latitude;
     waypoint.Location.Longitude = result.Locations[0].Longitude;
     return(waypoint);
 }
        private void GetRoute(List<Stop> stops)
        {
            // Create the service variable and set the callback method using the CalculateRouteCompleted property.
            RouteService.RouteServiceClient routeService = new RouteService.RouteServiceClient("BasicHttpBinding_IRouteService");
            routeService.CalculateRouteCompleted += new EventHandler<RouteService.CalculateRouteCompletedEventArgs>(routeService_CalculateRouteCompleted);

            // Set the token.
            RouteService.RouteRequest routeRequest = new RouteService.RouteRequest();
            routeRequest.Credentials = new Credentials();
            routeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)map1.CredentialsProvider).ApplicationId;

            // Return the route points so the route can be drawn.
            routeRequest.Options = new RouteService.RouteOptions();
            routeRequest.Options.RoutePathType = RouteService.RoutePathType.Points;

            routeRequest.Waypoints = new System.Collections.ObjectModel.ObservableCollection<RouteService.Waypoint>();
            int max = stops.Count() > 25 ? 25 : stops.Count();
            for (int i = 0; i < max; i++)
            {
                Stop stop = stops.ElementAt(i);
                RouteService.Waypoint srcWaypoint = new RouteService.Waypoint();
                srcWaypoint.Location = new GeoCoordinate((double)stop.Latitude, (double)stop.Longitude);
                routeRequest.Waypoints.Add(srcWaypoint);
            }

            // Make the CalculateRoute asnychronous request.
            routeService.CalculateRouteAsync(routeRequest);
        }
 //desc - pozwala ustawic wlasny opis waypointa
 private Waypoint GeocodeToWaypoint(GeocodeResult result, String desc = "")
 {
     RouteService.Waypoint waypoint = new RouteService.Waypoint();
     try
     {
         if (String.IsNullOrEmpty(desc))
             waypoint.Description = result.DisplayName;
         else
             waypoint.Description = desc;
         waypoint.Location = new Microsoft.Phone.Controls.Maps.Platform.Location();
         waypoint.Location.Latitude = result.Locations[0].Latitude;
         waypoint.Location.Longitude = result.Locations[0].Longitude;
     }
     catch
     {
         MessageBox.Show("Waypoint does not exist");
     }
     return waypoint;
 }
 private RouteService.Waypoint GeocodeResultToWaypoint(GeocodeService.GeocodeResult result)
 {
     RouteService.Waypoint waypoint = new RouteService.Waypoint();
     waypoint.Description = result.DisplayName;
     waypoint.Location = new RouteService.Location();
     waypoint.Location.Latitude = result.Locations[0].Latitude;
     waypoint.Location.Longitude = result.Locations[0].Longitude;
     return waypoint;
 }