private void RouteServiceTest(Location from, Location to) { var request = new RouteRequest { Options = new RouteOptions { RoutePathType = RoutePathType.Points }, ExecutionOptions = new ExecutionOptions { SuppressFaults = true } }; request.Waypoints = new ObservableCollection<Waypoint> {new Waypoint{ Location = from}, new Waypoint {Location = to} }; var client = new RouteServiceClient("BasicHttpBinding_IRouteService"); client.CalculateRouteCompleted += (o, args) => { if (args.Error == null) { var line = new MapPolyline { Locations = new LocationCollection(), Stroke = (Brush)Application.Current.Resources["PhoneAccentBrush"], StrokeThickness = 4 }; foreach (var point in args.Result.Result.RoutePath.Points) { line.Locations.Add(point); } map1.Children.Add(line); map1.SetView(LocationRect.CreateLocationRect(line.Locations)); //mapMain.ZoomLevel = 2; } }; var pushpinMicrosft = new Microsoft.Phone.Controls.Maps.Pushpin { Content = "Microsoft", Location = from, Background = (Brush)Application.Current.Resources["PhoneAccentBrush"] }; var pushpinGoogle = new Microsoft.Phone.Controls.Maps.Pushpin { Content = "Google", Location = to, Background = (Brush)Application.Current.Resources["PhoneAccentBrush"] }; map1.Children.Add(pushpinMicrosft); map1.Children.Add(pushpinGoogle); map1.CredentialsProvider.GetCredentials(credentials => { request.Credentials = credentials; client.CalculateRouteAsync(request); }); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)