コード例 #1
0
ファイル: Frm_Route.xaml.cs プロジェクト: lotusharley/xTrace
        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);
                }
            });
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Geopath"/> class, a
 /// Wpf-enabled wrapper for <see cref="Windows.Devices.Geolocation.Geopath"/>
 /// </summary>
 public Geopath(Windows.Devices.Geolocation.Geopath instance)
 {
     this.UwpInstance = instance;
 }