//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); } } }
/// <summary> /// Metodo para mostrar la ruta entr 2 puntos del mapa /// </summary> private async void mostrarRuta() { // Ubicacion del cliente BasicGeoposition startLocation = new BasicGeoposition() { Latitude = 37.390890, Longitude = -5.973330 }; // Tu ubicacion BasicGeoposition endLocation = new BasicGeoposition() { Latitude = 37.386983, Longitude = -5.973757 }; // Ruta entre los puntos MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { // Utilizar la ruta para inicializar MapRouteView MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; // Añade el nuevo MapRouteView a la coleccion de rutas del mapa MapControl1.Routes.Add(viewOfRoute); // Adapta el mapa a la ruta await MapControl1.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); } else { MapControl1.ZoomLevel = 10; } }
private async void ShowWayPointsAsync(object sender, ItemClickEventArgs e) { var route = (RouteClient)e.ClickedItem; Geolocator locator = new Geolocator(); locator.DesiredAccuracyInMeters = 1; BasicGeoposition point; var path2 = new List <Geopoint>(); var newRoute = new RouteClient() { RouteID = route.RouteID, Route = route.Route }; for (int i = 0; i < newRoute.Route.Count - 1; i++) { var cp1 = newRoute.Route[i]; var cp2 = newRoute.Route[i + 1]; point = new BasicGeoposition() { Latitude = converter.FromStringToDouble(cp1.Latitude), Longitude = converter.FromStringToDouble(cp1.Longitude) }; string speedString = Math.Abs(timeUtility.ComputeSpeed(cp1, cp2)).ToString(); string speed = speedString.Substring(0, 6); AddMarker(point, "Date: " + timeUtility.GetDate(cp1.CPDateTime) + "\n" + "Speed: " + speed + " m/s"); path2.Add(new Geopoint(point)); } var last = newRoute.Route[newRoute.Route.Count - 1]; point = new BasicGeoposition() { Latitude = converter.FromStringToDouble(last.Latitude), Longitude = converter.FromStringToDouble(last.Longitude) }; AddMarker(point, "Date: " + timeUtility.GetDate(last.CPDateTime) + "\n" + "Speed: 0 m/s"); path2.Add(new Geopoint(point)); MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(path2); if (routeResult.Status == MapRouteFinderStatus.Success) { if (PopupRouteInfo.IsOpen) { PopupRouteInfo.IsOpen = false; RouteListView.Items.Clear(); } if (PopupBeenHereInfo.IsOpen) { PopupBeenHereInfo.IsOpen = false; BeenHereListView.Items.Clear(); ButtonAutomationPeer peer = new ButtonAutomationPeer(PreviousRouteButton); IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv.Invoke(); } MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; MapControl1.Routes.Add(viewOfRoute); await MapControl1.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } }