private async void ShowRouteOnMap(Geopoint startPoint, Geopoint endPoint) { var routeResult = await MapRouteFinder.GetDrivingRouteAsync( startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { MapRouteView routeView = new MapRouteView(routeResult.Route); routeView.RouteColor = Colors.Yellow; routeView.OutlineColor = Colors.Black; MCMain.Routes.Add(routeView); } if (routeResult.Route == null) { MessageDialog dialog = new MessageDialog("No route found to this destination."); await dialog.ShowAsync(); } else { await MCMain.TrySetViewBoundsAsync(routeResult.Route.BoundingBox, null, MapAnimationKind.None); } }
private async void ShowRouteOnMap(BasicGeoposition startLocation, BasicGeoposition endLocation) { // Get the route between the points. MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRouteGlobal = viewOfRoute; viewOfRoute.RouteColor = Colors.Blue; viewOfRoute.OutlineColor = Colors.Black; // Add the new MapRouteView to the Routes collection // of the MapControl. mapaPodaci.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await mapaPodaci.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } }
private async void ShowRouteOnMap(BasicGeoposition l1, BasicGeoposition l2) { BasicGeoposition startLocation = l1; BasicGeoposition endLocation = l2; MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.DodgerBlue; viewOfRoute.OutlineColor = Colors.White; myMap.Routes.Clear(); myMap.Routes.Add(viewOfRoute); await myMap.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } }
private async Task <MapRouteFinderResult> GetCarRouteAsync(Location loc1, Location loc2) { // Start at Source BasicGeoposition startLocation = new BasicGeoposition(); startLocation.Latitude = loc1.latitude; startLocation.Longitude = loc2.longitude; Geopoint point1 = new Geopoint(startLocation); //AddPushpin(point1, loc1.name, "ms-appx:///Assets/bluePin50.png"); // End at Destination BasicGeoposition endLocation = new BasicGeoposition(); endLocation.Latitude = loc2.latitude; endLocation.Longitude = loc2.longitude; Geopoint point2 = new Geopoint(endLocation); //AddPushpin(point2, loc2.name, "ms-appx:///Assets/redPin50.png"); // Get the route between the points. MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( point1, point2); return(routeResult); }
public override async Task <IEnumerable <Models.Geoposition> > CalculateRoute(Models.Geoposition from, Models.Geoposition to) { Geopoint nativeFrom = CoordinateConverter.ConvertToNative(from); Geopoint nativeTo = CoordinateConverter.ConvertToNative(to); MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( nativeFrom, nativeTo, MapRouteOptimization.Time, MapRouteRestrictions.None); List <Models.Geoposition> result = new List <Models.Geoposition>(); IReadOnlyList <BasicGeoposition> routePositions = routeResult?.Route?.Path?.Positions; if (routePositions?.Any() == true) { foreach (BasicGeoposition position in routePositions) { result.Add(new Models.Geoposition { Latitude = position.Latitude, Longitude = position.Longitude }); } } return(result); }
/// <summary> /// Updates the travel distance and time info for the specified location, relative to the specified current location. /// </summary> /// <param name="location">The location to update.</param> /// <param name="currentLocation">The current location.</param> public static async Task UpdateTravelInfoAsync(LocationData location, LocationData currentLocation) { var routeResultTask = MapRouteFinder.GetDrivingRouteAsync( currentLocation.Geopoint, location.Geopoint, MapRouteOptimization.TimeWithTraffic, MapRouteRestrictions.None); var routeResultWithoutTrafficTask = MapRouteFinder.GetDrivingRouteAsync( currentLocation.Geopoint, location.Geopoint, MapRouteOptimization.Time, MapRouteRestrictions.None); MapRouteFinderResult routeResult = await routeResultTask; MapRouteFinderResult routeResultWithoutTraffic = await routeResultWithoutTrafficTask; if (routeResult.Status == MapRouteFinderStatus.Success) { location.FastestRoute = routeResult.Route; location.CurrentTravelDistance = Math.Round(routeResult.Route.LengthInMeters * 0.00062137, 1); // convert to miles location.CurrentTravelTime = (int)routeResult.Route.EstimatedDuration.TotalMinutes; location.Timestamp = DateTimeOffset.Now; if (routeResultWithoutTraffic.Status == MapRouteFinderStatus.Success) { location.CurrentTravelTimeWithoutTraffic = routeResultWithoutTraffic.Route.EstimatedDuration.Minutes; } else { // Fall back to the with-traffic value if the request fails. location.CurrentTravelTimeWithoutTraffic = routeResult.Route.EstimatedDuration.Minutes; } } else { throw new Exception(routeFinderUnavailableMessage); } }
public static async void ShowRoute(MapControl map, BasicGeoposition startLocation, BasicGeoposition endLocation) { //// Start at Microsoft in Redmond, Washington. //BasicGeoposition startLocation = new BasicGeoposition() { Latitude = 47.643, Longitude = -122.131 }; //// End at the city of Seattle, Washington. //BasicGeoposition endLocation = new BasicGeoposition() { Latitude = 47.604, Longitude = -122.329 }; // Get the route between the points. MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; // Add the new MapRouteView to the Routes collection // of the MapControl. map.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await map.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, MapAnimationKind.None); } }
private static async Task <double> GetDrivingDistanceAsync(Geopoint currentLocation, Sight sight) { MapService.ServiceToken = AppSettings.MapServiceToken; var mapRouteFinderResult = await MapRouteFinder.GetDrivingRouteAsync(currentLocation, sight.Location); return(mapRouteFinderResult.Route.LengthInMeters); }
private async void Plan_Route(Entidade e) { MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(this.current, e.geo, MapRouteOptimization.Time, MapRouteRestrictions.None, 290); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. try { map1.Routes.RemoveAt(0); } catch { //no route to remove } MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Blue; viewOfRoute.OutlineColor = Colors.Blue; // Add the new MapRouteView to the Routes collection // of the MapControl. map1.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await map1.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); } }
private async void routeBtn_Click(object sender, RoutedEventArgs e) { BasicGeoposition startPoint = new BasicGeoposition() { Latitude = 13.7617, Longitude = 100.5365 }; BasicGeoposition endPoint = new BasicGeoposition() { Latitude = 13.7642, Longitude = 100.5401 }; MapRouteFinderResult routeFinder = await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(startPoint), new Geopoint(endPoint), MapRouteOptimization.Distance, MapRouteRestrictions.None); if (routeFinder.Status == MapRouteFinderStatus.Success) { MapRouteView view = new MapRouteView(routeFinder.Route) { RouteColor = Colors.Blue, OutlineColor = Colors.Yellow }; myMap.Routes.Add(view); await myMap.TrySetViewBoundsAsync(routeFinder.Route.BoundingBox, null, MapAnimationKind.None); } }
private async void MapItemsStack_Holding(object sender, HoldingRoutedEventArgs e) { var selectedItem = (Entidade)(sender as StackPanel).DataContext; Debug.WriteLine("new ROUTE TO: " + selectedItem.Nome); MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(this.current, selectedItem.geo, MapRouteOptimization.Time, MapRouteRestrictions.None, 290); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. try { map1.Routes.RemoveAt(0); } catch { //no route to remove } MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Blue; viewOfRoute.OutlineColor = Colors.Blue; // Add the new MapRouteView to the Routes collection // of the MapControl. map1.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await map1.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); } }
private async void AddRouteView(Route route) { if (mapControl == null) { return; } var startLocation = route.StartLocation.ToBasicGeoposition(); var endLocation = route.EndLocation.ToBasicGeoposition(); MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteAsync( new Geopoint(startLocation), new Geopoint(endLocation)); if (routeResult.Status == MapRouteFinderStatus.Success) { var routeView = new MapRouteView(routeResult.Route) { RouteColor = Windows.UI.Colors.Yellow, OutlineColor = Windows.UI.Colors.Black, }; mapControl.Routes.Add(routeView); renderedRoute.Add(route, routeView); } }
private async void CalculateRoute() { Geolocator locator = new Geolocator(); Geoposition geopos = null; try { geopos = await locator.GetGeopositionAsync(); Set_Map(geopos.Coordinate.Point, "Start"); Geopoint eind = new Geopoint(new BasicGeoposition() { Latitude = current_spot.Latitude, Longitude = current_spot.Longitude }); MapRouteFinderResult result = await MapRouteFinder.GetWalkingRouteAsync(geopos.Coordinate.Point, eind); if (result.Status == MapRouteFinderStatus.Success) { MapRouteView view = new MapRouteView(result.Route); view.RouteColor = Colors.Blue; view.OutlineColor = Colors.Red; MapControlLocation.Routes.Add(view); await MapControlLocation.TrySetViewBoundsAsync(result.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); } } catch (Exception ex) { ErrorMap(); } }
private async void ShowRouteOnMap(Geopoint startPoint, Geopoint endPoint) { //Creates the coloured trail to guide the user using there GPS MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None); // Do the following if maps route is found if (routeResult.Status == MapRouteFinderStatus.Success) { myMap.Routes.Clear(); MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; myMap.Routes.Add(viewOfRoute); await myMap.TrySetViewBoundsAsync(routeResult.Route.BoundingBox, null, MapAnimationKind.None); } else { // Handle the error of no map route var message = new MessageDialog("Can't find routes"); await message.ShowAsync(); } }
private async System.Threading.Tasks.Task routeCreateAsync(Geopoint g1, Geopoint g2) { // Get the route between the points. MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteAsync(g1, g2); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; // Add the new MapRouteView to the Routes collection // of the MapControl. map.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await map.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } }
//Here we get the user's position using C++ //private async Task GetUserPositionCPlusPlus() //{ // var cPlusPlusClassInstance = new CppProj.Class1(); // var position = await cPlusPlusClassInstance.ReturnPosition(); // var x = position.Coordinate; // var speed = position.Coordinate.Speed; //} private async void ShowPath() { if (path.Count >= 2) { foreach (var geoPoint in path) { AddMarkerUserPos(geoPoint, timeUtility.GetTime(DateTime.Now)); } MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(path); if (routeResult.Status == MapRouteFinderStatus.Success) { MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; MapControl1.Routes.Add(viewOfRoute); MapControl1.ZoomLevel = 17; await MapControl1.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } } }
private async void CinemaListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { MyMap.Routes.Clear(); ListView Lis = sender as ListView; CinemaRecommendViewModel _poi = Lis.DataContext as CinemaRecommendViewModel; if (Lis.SelectedIndex == -1) { return; } Pois poi = _poi.poiresult[Lis.SelectedIndex] as Pois; string[] arr = poi.location.Split(','); BasicGeoposition startLocation = new BasicGeoposition() { Latitude = myLocation.Position.Latitude, Longitude = myLocation.Position.Longitude }; BasicGeoposition endLocation = new BasicGeoposition() { Latitude = Convert.ToDouble(arr[1]), Longitude = Convert.ToDouble(arr[0]) }; MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; MyMap.Routes.Add(viewOfRoute); await MyMap.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, MapAnimationKind.None); } }
private async void FindRoutesAsync(object sender, RoutedEventArgs e) { if (ToASB.Text == string.Empty) { await new MessageDialog("Please enter the destination").ShowAsync(); } if (FromASB.Text == string.Empty) { fromGeopoint = geopoint; } MapRouteFinderResult routeFinderResults = await MapRouteFinder.GetDrivingRouteAsync(fromGeopoint, toGeopoint, MapRouteOptimization.TimeWithTraffic, MapRouteRestrictions.None); if (routeFinderResults.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeFinderResults.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; // Add the new MapRouteView to the Routes collection // of the MapControl. mapControl.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await mapControl.TrySetViewBoundsAsync( routeFinderResults.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } else { await new MessageDialog("No route found").ShowAsync(); } }
public async Task <MapRouteFinderResult> GetRouteToPoint(BasicGeoposition start, BasicGeoposition end) { return(await MapRouteFinder.GetDrivingRouteAsync( new Geopoint(start), new Geopoint(end), MapRouteOptimization.Time, MapRouteRestrictions.None)); }
private static async Task <double> GetDrivingDistanceAsync(Geopoint fromLocation, Geopoint toLocation) { MapService.ServiceToken = AppSettings.MapServiceToken; var mapRouteFinderResult = await MapRouteFinder.GetDrivingRouteAsync(toLocation, toLocation); // returns 10000 if no route can be found return(mapRouteFinderResult.Route?.LengthInMeters ?? 10000); }
internal static async Task <MapRouteFinderResult> UpdatePhone(bool p) { Phone.Visibility = p ? Visibility.Visible : Visibility.Collapsed; if (p) { return(await MapRouteFinder.GetWalkingRouteAsync(Phone.Location, Kot.Location)); } return(null); }
private async void MapControl_Loaded(object sender, RoutedEventArgs e) { var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; //Geopoint start = new Geopoint(new BasicGeoposition() //{ // Latitude = Convert.ToDouble(localSettings.Values["Event_startLatitude"]), // Longitude = Convert.ToDouble(localSettings.Values["Event_startLongitude"]), //}); //Geopoint end = new Geopoint(new BasicGeoposition() //{ // Latitude = Convert.ToDouble(localSettings.Values["Event_endLatitude"]), // Longitude = Convert.ToDouble(localSettings.Values["Event_endLongitude"]), //}); MapControl.Center = _startGeopoint; MapControl.LandmarksVisible = true; MapControl.ZoomLevel = 12; MapIcon startIcon = new MapIcon { Location = _startGeopoint, ZIndex = 0 }; MapControl.MapElements.Add(startIcon); MapIcon endIcon = new MapIcon { Location = _endGeopoint, ZIndex = 0 }; MapControl.MapElements.Add(endIcon); MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( startIcon.Location, endIcon.Location, MapRouteOptimization.Time, MapRouteRestrictions.None ); if (routeResult.Status != MapRouteFinderStatus.Success) { return; } MapRouteView viewOfRoute = new MapRouteView(routeResult.Route) { RouteColor = Colors.Yellow, OutlineColor = Colors.Black }; MapControl.Routes.Add(viewOfRoute); await MapControl.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); }
public static async void DrawRoute(MapControl map, UwpUser user, UwpUser friend) { map.Routes.Clear(); MapRouteFinderResult result = await MapRouteFinder.GetWalkingRouteAsync(user.Location, friend.Location); MapRouteView route = new MapRouteView(result.Route); route.RouteColor = Colors.Blue; map.Routes.Add(route); }
public static async Task <MapRoute> ResolveMapRouteAsync(Geopoint fromLocation, Geopoint toLocation) { MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( fromLocation, toLocation, MapRouteOptimization.Time, MapRouteRestrictions.None); return(routeResult.Status == MapRouteFinderStatus.Success ? routeResult.Route : null); }
/// <summary> /// Calculate the route between two geopositons /// </summary> /// <param name="source">The location of the source as Geoposition</param> /// <param name="target">The location to calculate the distance to</param> /// <returns>MapRoute between the two points <seealso cref="MapRoute" /></returns> public static async Task <MapRoute> GetRouteTo(Geopoint source, Geopoint target) { var result = await MapRouteFinder.GetWalkingRouteAsync(source, target); if (result.Status == MapRouteFinderStatus.Success) { return(result.Route); } return(null); }
private async void MapControl_MapTapped(MapControl sender, MapInputEventArgs args) { Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; int icons = Convert.ToInt32(localSettings.Values["icons"]); var tappedGeoPosition = args.Location.Position; tblock_latitude.Text = tappedGeoPosition.Latitude.ToString(); tblock_longitude.Text = tappedGeoPosition.Longitude.ToString(); if ((icons > 1) && (_first != 0)) { tb_Description.Text = icons.ToString(); MapControl.MapElements.Clear(); MapControl.Routes.Clear(); icons = 0; } else { MapIcon icon = new MapIcon(); icon.Location = new Geopoint(tappedGeoPosition); icon.ZIndex = 0; MapControl.MapElements.Add(icon); icons++; _first++; if (icons == 1) { _startLocation = icon.Location; } else { _endLocation = icon.Location; MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( _startLocation, _endLocation, MapRouteOptimization.Time, MapRouteRestrictions.None ); if (routeResult.Status == MapRouteFinderStatus.Success) { MapRouteView viewOfRoute = new MapRouteView(routeResult.Route) { RouteColor = Colors.Yellow, OutlineColor = Colors.Black }; MapControl.Routes.Add(viewOfRoute); await MapControl.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } } } localSettings.Values["icons"] = icons; }
public async Task CalculateRouteAsync() { MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( Location, UserLocation, MapRouteOptimization.Time, MapRouteRestrictions.None); RouteView = new MapRouteView(routeResult.Route); Map.Routes.Add(RouteView); }
private async void lsvCitas_ItemClick(object sender, ItemClickEventArgs e) { mapa.Routes.Remove(vistaRuta); var cita = e.ClickedItem as Cita; //Para mostrar una ruta, necesitamos el punto de inicio, que lo pondremos como el instituto BasicGeoposition bgInstituto = new BasicGeoposition() { Latitude = 37.373774, Longitude = -5.969034 }; Geopoint instituto = new Geopoint(bgInstituto); //Esto es una pista de dónde empezar a buscar la latitud y la longitud de la dirección del cliente BasicGeoposition pista = new BasicGeoposition(); pista.Latitude = 40.416775; pista.Longitude = -3.703790; Geopoint madrid = new Geopoint(pista); //Nos devuelve las coordenadas MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(cita.direccion, madrid); //Si encuentra la localización if (result.Status == MapLocationFinderStatus.Success) { //Esto es el BasicGeoposition con las coordenadas BasicGeoposition posicion = result.Locations[0].Point.Position; Geopoint centro = new Geopoint(posicion); //Intentamos buscar una ruta con coche del instituto a la dirección de destino MapRouteFinderResult ruta = await MapRouteFinder.GetDrivingRouteAsync(instituto, centro); if(ruta.Status == MapRouteFinderStatus.Success) { //Si la encuentra, creamos la MapRouteView (que es lo que el MapControl acepta y se lo añadimos vistaRuta = new MapRouteView(ruta.Route); //También podemos cambiar el color de la línea de la ruta vistaRuta.RouteColor = Colors.Red; vistaRuta.OutlineColor = Colors.Black; //Y se lo añadimos al MapControl mapa.Routes.Add(vistaRuta); } //Ahora ponemos bien el mapa mapa.Center = centro; mapa.ZoomLevel = 17; } }
async private void OnPositionChanged(Geolocator sender, PositionChangedEventArgs e) { if (!tracking) { point = e.Position.Coordinate.Point; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { icon.Location = point; }); await myMap.TrySetViewAsync(point); } else { currentPoint = e.Position.Coordinate.Point; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { icon.Location = currentPoint; }); MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteAsync(point, currentPoint); if (routeResult.Route == null) { return; } if (routeResult.Status == MapRouteFinderStatus.Success) { await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { //directionChanged MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Blue; viewOfRoute.OutlineColor = Colors.Blue; myMap.Routes.Add(viewOfRoute); }); Distance += routeResult.Route.LengthInMeters; point = currentPoint; await Dispatcher.RunAsync( CoreDispatcherPriority.High, () => { distanceBlock.Text = Distance.ToString() + "m"; }); //distanceBlock.Text = Distance.ToString() + "m"; } await myMap.TrySetViewAsync(currentPoint); } }
private async void OnSuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args) { if (sender.ItemsSource == _failedMessageItemSource) { sender.Text = string.Empty; return; } var suggestion = args.SelectedItem as LocationSuggestion; _currentRouteResult = await MapRouteFinder.GetDrivingRouteAsync(CurrentPosition, suggestion.Location.Point); switch (_currentRouteResult.Status) { case MapRouteFinderStatus.Success: FocusResult.Visibility = Visibility.Visible; NavigationLabel.Text = suggestion.Location.Address.Town; DescriptionLabel.Text = suggestion.Location.Description; var thing = await NavigationServices.GetPlaceMetaData(suggestion.Location.Address.Town); break; case MapRouteFinderStatus.UnknownError: break; case MapRouteFinderStatus.InvalidCredentials: break; case MapRouteFinderStatus.NoRouteFound: break; case MapRouteFinderStatus.NoRouteFoundWithGivenOptions: break; case MapRouteFinderStatus.StartPointNotFound: break; case MapRouteFinderStatus.EndPointNotFound: break; case MapRouteFinderStatus.NoPedestrianRouteFound: break; case MapRouteFinderStatus.NetworkFailure: sender.ItemsSource = "No internet connection"; break; case MapRouteFinderStatus.NotSupported: break; } }