public void updateUIMap() { point oldPoint = null; foreach (point pointElement in GPSLocator.track) { if (oldPoint != null) { Windows.UI.Xaml.Controls.Maps.MapPolyline mapPolyline = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); mapPolyline.Path = new Geopath(new List <BasicGeoposition>() { new BasicGeoposition() { Latitude = oldPoint.latitude, Longitude = oldPoint.longitude }, new BasicGeoposition() { Latitude = pointElement.latitude, Longitude = pointElement.longitude } }); mapPolyline.StrokeColor = Colors.Black; mapPolyline.StrokeThickness = 3; mapPolyline.StrokeDashed = true; MapControl1.MapElements.Add(mapPolyline); } oldPoint = pointElement; } }
private void searchRoute_Click(object sender, RoutedEventArgs e) { if (startIcon == null || endIcon == null) { return; } var cycleWays = routerDb.HasContractedFor(Itinero.Osm.Vehicles.Vehicle.Bicycle.Fastest()); var cycleProfiles = new List <Itinero.Profiles.Profile>(Itinero.Osm.Vehicles.Vehicle.Bicycle.GetProfiles()); var profile = cycleProfiles[0]; var edgeFunc = new Func <Itinero.Data.Network.RoutingEdge, bool>((edge) => { Console.WriteLine(edge.ToString() + " " + edge.Data.Distance); if (edge.Data.Distance > 40) { return(true); } return(false); }); //var start = router.Resolve(new Itinero.Profiles.Profile[] { profile }, (float)startIcon.Location.Position.Latitude, (float)startIcon.Location.Position.Longitude, edgeFunc); var start = router.Resolve(profile, (float)startIcon.Location.Position.Latitude, (float)startIcon.Location.Position.Longitude, 100); var end = router.Resolve(profile, (float)endIcon.Location.Position.Latitude, (float)endIcon.Location.Position.Longitude, 100); try { var route = router.Calculate(profile, start, end); var routeGeoJson = route.ToGeoJson(); //Console.WriteLine(routeGeoJson); Console.WriteLine($"Time: {route.TotalTime / 60f}"); foreach (var c in route.Shape) { Console.WriteLine($"new BasicGeoposition() {{ Latitude = {c.Latitude}f, Longitude = {c.Longitude}f }},"); } var mPoly = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); var positions = route.Shape.ToList().ConvertAll <BasicGeoposition>(s => new BasicGeoposition() { Latitude = s.Latitude, Longitude = s.Longitude }); mPoly.Path = new Geopath(positions); map.MapElements.Clear(); map.MapElements.Add(startIcon); map.MapElements.Add(endIcon); map.MapElements.Add(mPoly); } catch (Exception) { Console.WriteLine("No route found"); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { // We are going to cast the property Parameter of NavigationEventArgs object Route = e.Parameter as IRoute; Route.PropertyChanged += Route_PropertyChanged; RootGrid.DataContext = this as RouteSheet; Windows.UI.Xaml.Controls.Maps.MapPolyline line = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); line.Path = new Windows.Devices.Geolocation.Geopath(Route.Track); MainPage.Current.MapMain.MapElements.Add(line); if (Route != null) CreateAppBarButtons(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // We are going to cast the property Parameter of NavigationEventArgs object Route = e.Parameter as IRoute; Route.PropertyChanged += Route_PropertyChanged; RootGrid.DataContext = this as RouteSheet; Windows.UI.Xaml.Controls.Maps.MapPolyline line = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); line.Path = new Windows.Devices.Geolocation.Geopath(Route.Track); MainPage.Current.MapMain.MapElements.Add(line); if (Route != null) { CreateAppBarButtons(); } }
private async void DrawFlightPlane() { List<Windows.Devices.Geolocation.BasicGeoposition> geopoints = new List<Windows.Devices.Geolocation.BasicGeoposition>(); //Windows.Devices.Geolocation.Geopath geopath = new Windows.Devices.Geolocation.Geopath() List<Windows.UI.Xaml.Controls.Maps.MapIcon> waypointIcons = new List<Windows.UI.Xaml.Controls.Maps.MapIcon>(); foreach (DataModel.XNavpoint point in flightplan.Waypoints) { navpoints.Add(point); geopoints.Add(new Windows.Devices.Geolocation.BasicGeoposition() { Longitude = double.Parse(point.Longtitude) / 1000000 - 0.000005, Latitude = double.Parse(point.Lantitude) / 1000000 - 0.000005 }); System.Diagnostics.Debug.WriteLine(double.Parse(point.Longtitude) / 1000000 + " " + double.Parse(point.Lantitude) / 1000000); Windows.UI.Xaml.Controls.Maps.MapIcon icon = new Windows.UI.Xaml.Controls.Maps.MapIcon(); icon.Image = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/navpoint.png")); icon.Location = new Windows.Devices.Geolocation.Geopoint(new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = double.Parse(point.Lantitude) / 1000000 - 0.000005, Longitude = double.Parse(point.Longtitude)/1000000 - 0.000005 }); icon.NormalizedAnchorPoint = new Point(0.5, 1.0); icon.Title = point.PointName; waypointIcons.Add(icon); } Windows.Devices.Geolocation.Geopath geopath = new Windows.Devices.Geolocation.Geopath(geopoints); await rootFrame.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Windows.UI.Xaml.Controls.Maps.MapControl themap = (Windows.UI.Xaml.Controls.Maps.MapControl)rootFrame.FindName("themap"); Windows.UI.Xaml.Controls.Maps.MapPolyline line = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); line.Path = geopath; line.StrokeColor = Windows.UI.Colors.Red; line.StrokeDashed = true; line.StrokeThickness = 3; themap.MapElements.Clear(); themap.MapElements.Add(line); foreach(Windows.UI.Xaml.Controls.Maps.MapIcon icon in waypointIcons) { themap.MapElements.Add(icon); } }); }