//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 button1_Click(object sender, RoutedEventArgs e) { if (MapControl1.Is3DSupported) { MapControl1.Style = MapStyle.Aerial3D; BasicGeoposition hwGeoposition = new BasicGeoposition() { Latitude = 48.858, Longitude = 2.295 }; Geopoint hwPoint = new Geopoint(hwGeoposition); MapScene hwScene = MapScene.CreateFromLocationAndRadius(hwPoint, 80, 0, 60); await MapControl1.TrySetSceneAsync(hwScene, MapAnimationKind.Bow); } else { ContentDialog viewNotSupportedDialog = new ContentDialog() { Title = "3D is not supported", Content = "\n3D views are not supported on this device.", PrimaryButtonText = "OK" }; await viewNotSupportedDialog.ShowAsync(); } }
/// <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 display3DLocation() { BasicGeoposition cityPosition = new BasicGeoposition() { Latitude = 55.6509863734914, Longitude = 37.6680877307923, Altitude = 10 }; SeattleLocation1 = new Geopoint(cityPosition); Geopoint cityCenter = new Geopoint(cityPosition); if (MapControl1.Is3DSupported) { // Set the aerial 3D view. MapControl1.Style = MapStyle.Terrain; // Specify the location. BasicGeoposition hwGeoposition = new BasicGeoposition() { Latitude = cityCenter.Position.Latitude, Longitude = cityCenter.Position.Longitude, Altitude = cityCenter.Position.Altitude }; Geopoint hwPoint = new Geopoint(hwGeoposition); // Create the map scene. MapScene hwScene = MapScene.CreateFromLocationAndRadius(hwPoint, 80, /* show this many meters around */ 0, /* looking at it to the North*/ 60 /* degrees pitch */); // Set the 3D view with animation. await MapControl1.TrySetSceneAsync(hwScene, MapAnimationKind.Bow); } else { // If 3D views are not supported, display dialog. ContentDialog viewNotSupportedDialog = new ContentDialog() { Title = "3D is not supported", Content = "\n3D views are not supported on this device.", PrimaryButtonText = "OK" }; await viewNotSupportedDialog.ShowAsync(); } }
// Locate Me Bottom App Bar private async void LocateMe_Click(object sender, RoutedEventArgs e) { LocateMe.Visibility = Windows.UI.Xaml.Visibility.Visible; geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 50; try { Geoposition geoposition = await geolocator.GetGeopositionAsync( maximumAge : TimeSpan.FromMinutes(5), timeout : TimeSpan.FromSeconds(10)); await MapControl1.TrySetViewAsync(geoposition.Coordinate.Point, 18D); mySlider.Value = MapControl1.ZoomLevel; //LocateMe.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } catch (UnauthorizedAccessException) { MessageBox("Location service is turned off!"); } }
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); } }