当前位置: 首页>>代码示例>>C#>>正文


C# MapPolyline类代码示例

本文整理汇总了C#中MapPolyline的典型用法代码示例。如果您正苦于以下问题:C# MapPolyline类的具体用法?C# MapPolyline怎么用?C# MapPolyline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MapPolyline类属于命名空间,在下文中一共展示了MapPolyline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeLine

 //Initialize the route line indicator. 
 private void InitializeLine()
 {
     _line = new MapPolyline();
     _line.StrokeColor = Colors.Red;
     _line.StrokeThickness = 5;
     Map.MapElements.Add(_line);
 }
开发者ID:KristofColpaert,项目名称:BikeToWork,代码行数:8,代码来源:MainPage.xaml.cs

示例2: webClient_DownloadStringCompleted

        void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            var rootObject = JsonConvert.DeserializeObject<Rootobject>(e.Result);
            double lat, longitude;
            MapPolyline line = new MapPolyline();
            line.StrokeColor = Colors.Green;
            line.StrokeThickness = 2;

            double[] coord = new double[2 * rootObject.direction[0].stop.Length];
            for (int i = 0; i < rootObject.direction[0].stop.Length; i++)
            {
                lat = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lat);
                longitude = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lon);

                line.Path.Add(new GeoCoordinate(lat, longitude));

                Ellipse myCircle = new Ellipse();
                myCircle.Fill = new SolidColorBrush(Colors.Green);
                myCircle.Height = 15;
                myCircle.Width = 15;
                myCircle.Opacity = 60;
                MapOverlay myLocationOverlay = new MapOverlay();
                myLocationOverlay.Content = myCircle;
                myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
                myLocationOverlay.GeoCoordinate = new GeoCoordinate(lat, longitude, 200);
                MapLayer myLocationLayer = new MapLayer();
                myLocationLayer.Add(myLocationOverlay);
                map.Layers.Add(myLocationLayer);
            }
            map.MapElements.Add(line);
        }
开发者ID:huyle333,项目名称:windowsapp2013,代码行数:31,代码来源:GreenLine.xaml.cs

示例3: MainPage

        public MainPage()
        {
            InitializeComponent();
            mainDatabase = new WorkoutDatabase();
            lastGPSlocation = null;
            joggingPolyLine = new MapPolyline();
            joggingPolyLine.Stroke = new SolidColorBrush(Colors.Blue);
            joggingPolyLine.StrokeThickness = 5;
            joggingPolyLine.Opacity = 0.7;
            joggingPolyLine.Locations = new LocationCollection();
            map1.Children.Add(joggingPolyLine);
            string deviceName = Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString();

            if (deviceName == "XDeviceEmulator")                                                                    // Checks for device name in order to determine whether to simulate a jogger or not
            {
                //Note: The following coordinates is just a Test coordinate for when running the GeoCoordinate simulator
               geowatcher = new GeoCoordinateSimulator(51.5941116666667, 4.77941666666667);

            }
            else
            {
                geowatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            }
            geowatcher.PositionChanged += watcher_PositionChanged;
            //The next line is responsible for loading the database from Isolated Storage. The loading and saving implementation works HOWEVER, It is NOT loaded properly and the previous workoutlist does not display previously saved workouts.
               // mainDatabase = dataSave.loadDatabaseFromIsolatedStorage("WorkoutDatabase");

               // checkIfFileExists();
        }
开发者ID:bemk,项目名称:wp7app,代码行数:29,代码来源:MainPage.xaml.cs

示例4: WorkoutMapStatisticsPage

        public WorkoutMapStatisticsPage()
        {
            InitializeComponent();
            routeLine = new MapPolyline();
            routeLine.Locations = selectedWorkout.routeLine.Locations; // Where the magic happens: Note: ALL routes MUST have a polyline, otherwise the application WILL ofcourse, CRASH!
            routeLine.Stroke = new SolidColorBrush(Colors.Blue);
            routeLine.StrokeThickness = 5;
            Pushpin pStart = new Pushpin();
            pStart.Content = "Start";
            pStart.Background = new SolidColorBrush(Colors.Green);
            Pushpin pFinish = new Pushpin();
            pFinish.Content = "Finish";
            pFinish.Background = new SolidColorBrush(Colors.Red);
            layer.AddChild(pStart, new GeoCoordinate(routeLine.Locations.First().Latitude, routeLine.Locations.First().Longitude));
            layer.AddChild(pFinish, new GeoCoordinate(routeLine.Locations.Last().Latitude, routeLine.Locations.Last().Longitude));
            map2.Children.Add(routeLine);
            map2.Children.Add(layer);
            textBlock5.Text = selectedWorkout.workoutName;
            textBlock6.Text = selectedWorkout.startTime;
            textBlock7.Text = String.Format("{0:F2}", selectedWorkout.distanceRan);
            textBlock8.Text = string.Format("{0:00}:{1:00}:{2:00}",
               selectedWorkout.elapsedTimeTS.Hours,
                selectedWorkout.elapsedTimeTS.Minutes,
                selectedWorkout.elapsedTimeTS.Seconds); ;

            double latitude;
            double longitude;
            getWorkoutRouteLocation(out latitude, out longitude);

            map2.Center = new GeoCoordinate(latitude, longitude);
            map2.ZoomLevel = 16;
        }
开发者ID:bemk,项目名称:wp7app,代码行数:32,代码来源:WorkoutMapStatisticsPage.xaml.cs

示例5: Map_Loaded

        private void Map_Loaded(object sender, RoutedEventArgs e)
        {
            Ellipse myCircle = new Ellipse();
            MapPolyline line = new MapPolyline();

            WebClient blue = new WebClient();
            line.StrokeColor = Colors.Blue;
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            blue.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            blue.DownloadStringAsync(new Uri(blue946));
            WebClient green1 = new WebClient();
            line.StrokeColor = Colors.Green;
            myCircle.Fill = new SolidColorBrush(Colors.Green);
            green1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            green1.DownloadStringAsync(new Uri(green810));
            WebClient green2 = new WebClient();
            line.StrokeColor = Colors.Green;
            green2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            green2.DownloadStringAsync(new Uri(green830));
                    line.StrokeColor = Colors.Green;;
            WebClient green3 = new WebClient();
            green3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            green3.DownloadStringAsync(new Uri(green852));
                    line.StrokeColor = Colors.Green;
            WebClient orange = new WebClient();
            line.StrokeColor = Colors.Orange;
            myCircle.Fill = new SolidColorBrush(Colors.Orange);
            orange.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            orange.DownloadStringAsync(new Uri(orange903));
            WebClient red = new WebClient();
            myCircle.Fill = new SolidColorBrush(Colors.Red);
            line.StrokeColor = Colors.Red;
            red.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            red.DownloadStringAsync(new Uri(red931));
        }
开发者ID:huyle333,项目名称:windowsapp2013,代码行数:35,代码来源:Map.xaml.cs

示例6: OnElementChanged

        protected override void OnElementChanged(ElementChangedEventArgs<Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe
            }

            if (e.NewElement != null)
            {
                var formsMap = (CustomMap)e.NewElement;
                var nativeMap = Control as MapControl;

                var coordinates = new List<BasicGeoposition>();
                foreach (var position in formsMap.RouteCoordinates)
                {
                    coordinates.Add(new BasicGeoposition() { Latitude = position.Latitude, Longitude = position.Longitude });
                }

                var polyline = new MapPolyline();
                polyline.StrokeColor = Windows.UI.Color.FromArgb(128, 255, 0, 0);
                polyline.StrokeThickness = 5;
                polyline.Path = new Geopath(coordinates);
                nativeMap.MapElements.Add(polyline);
            }
        }
开发者ID:jcaristy,项目名称:recipes,代码行数:27,代码来源:CustomMapRenderer.cs

示例7: DrawLines

    private void DrawLines(object sender, RoutedEventArgs e)
    {
        if (!DeleteShapesFromLevel(4))
        {
            var strokeColor = Colors.Green;

            //Drawing lines, notice the use of Geopath. Consists out of BasicGeopositions
            foreach (var dataObject in PointList.GetLines())
            {
                ///////////////////////////////////////////////////
                // Creating the a MapPolyLine 
                //   (stroke, path (list of BasicGeopositions)
                var shape = new MapPolyline
                {
                    StrokeThickness = 9,
                    StrokeColor = strokeColor,
                    StrokeDashed = false,
                    ZIndex = 4,
                    Path = new Geopath(dataObject.Points.Select(p => p.Position))
                };
                shape.AddData(dataObject);

                MyMap.MapElements.Add(shape);
            }
        }
    }
开发者ID:MuffPotter,项目名称:201505-MVA,代码行数:26,代码来源:MainPage.xaml.cs

示例8: SetAnimDash

        public void SetAnimDash(PointCollection pc, ShapeLayer layer)
        {
            MapPolyline animDashLine = new MapPolyline()
            {
                MapStrokeThickness = 20,
                Points = pc,
                ScaleFactor = 0.2
            };

            animDashLine.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, 255, 255, 255));
            animDashLine.StrokeLineJoin = PenLineJoin.Round;
            animDashLine.StrokeStartLineCap = PenLineCap.Flat;
            animDashLine.StrokeEndLineCap = PenLineCap.Triangle;
            animDashLine.StrokeDashCap = PenLineCap.Triangle;
            var dc = new DoubleCollection { 2, 2 };
            animDashLine.IsHitTestVisible = false;
            animDashLine.StrokeDashArray = dc;

            DoubleAnimation animation = new DoubleAnimation
            {
                From = 4,
                To = 0,
                FillBehavior = System.Windows.Media.Animation.FillBehavior.HoldEnd,
                RepeatBehavior = RepeatBehavior.Forever
            };

            var strokeStoryboard = new Storyboard();
            strokeStoryboard.Children.Add(animation);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(Line.StrokeDashOffset)"));
            Storyboard.SetTarget(animation, animDashLine);
            strokeStoryboard.Begin();
            layer.Shapes.Add(animDashLine);
        }
开发者ID:MuffPotter,项目名称:xservernet-bin,代码行数:33,代码来源:Window1.xaml.cs

示例9: HandleMapPath

 /// <summary>
 /// Handles MVVM Message for Map path.
 /// </summary>
 /// <param name="path">The path.</param>
 private void HandleMapPath(Geopath path)
 {
     // Remove previous paths from MapControl
     mapActivity.MapElements.Clear();
     // Validate input path
     if (path != null &&
         path.Positions.Any())
     {
         // Configure path to draw with polyline and assign path to MapControl
         MapPolyline loMapPolyline = new MapPolyline();
         loMapPolyline.Path = path;
         loMapPolyline.StrokeColor = (Color)Resources["SystemAccentColor"];
         loMapPolyline.StrokeThickness = 3;
         mapActivity.MapElements.Add(loMapPolyline);
         // Configure start position icon and assign path to MapControl
         BasicGeoposition loStartPosition = path.Positions[0];
         MapIcon loStartIcon = new MapIcon();
         loStartIcon.Location = new Geopoint(loStartPosition);
         loStartIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
         loStartIcon.Title = XportBand.Resources.Strings.MapPositionStartText;
         loStartIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/LocationDarkGreen.png"));
         mapActivity.MapElements.Add(loStartIcon);
         // Configure end position icon and assign path to MapControl
         BasicGeoposition loEndPosition = path.Positions[path.Positions.Count - 1];
         MapIcon loEndIcon = new MapIcon();
         loEndIcon.Location = new Geopoint(loEndPosition);
         loEndIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
         loEndIcon.Title = XportBand.Resources.Strings.MapPositionEndText;
         loEndIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/LocationDarkRed.png"));
         mapActivity.MapElements.Add(loEndIcon);
         // Center map to start position and assign default zoom level to 15 (TODO: auto-zoom)
         mapActivity.Center = new Geopoint(loStartPosition);
         mapActivity.ZoomLevel = 15;
     }
 }
开发者ID:yorchideas,项目名称:XportBand,代码行数:39,代码来源:ActivityDetailsView.xaml.cs

示例10: DrawPolyline

        private async Task DrawPolyline(List<BasicGeoposition> geopositions)
        {
            ActivityMap.MapElements.Clear();

            if (geopositions.Any())
            {
                var polyLine = new MapPolyline { Path = new Geopath(geopositions), StrokeThickness = 4, StrokeColor = (Color)App.Current.Resources["StravaRedColor"] };
                ActivityMap.MapElements.Add(polyLine);

                MapIcon startMapIcon = new MapIcon();
                startMapIcon.Location = new Geopoint(geopositions.First());
                startMapIcon.NormalizedAnchorPoint = new Point(0.5, 0.5);
                startMapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Start.png"));
                ActivityMap.MapElements.Add(startMapIcon);

                MapIcon endMapIcon = new MapIcon();
                endMapIcon.Location = new Geopoint(geopositions.Last());
                endMapIcon.NormalizedAnchorPoint = new Point(0.5, 0.5);
                endMapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/End.png"));
                ActivityMap.MapElements.Add(endMapIcon);

                var zoomed = false;
                while (!zoomed)
                    zoomed = await ActivityMap.TrySetViewBoundsAsync(GeoboundingBox.TryCompute(geopositions), null, MapAnimationKind.None);
            }
        }
开发者ID:cgourlay,项目名称:Kliva,代码行数:26,代码来源:ActivityDetailControl.xaml.cs

示例11: Route

        public Route()
        {
            // default settings
            route = new MapPolyline();
            route.Stroke = new SolidColorBrush(Colors.Blue);
            route.StrokeThickness = 5;
            route.Opacity = 0.7;

            route.Locations = RouteFromLocations();
        }
开发者ID:jasonbw,项目名称:Runner,代码行数:10,代码来源:Route.cs

示例12: map1_MouseLeftButtonUp

        void map1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Debug.WriteLine("map_MouseLeftButtonUp " + markerSelected + ", addPoint: " + addPoint);

            if (addPoint)
            {

                if (markerLayer == null) // create layer if it does not exists yet
                {
                    markerLayer = new MapLayer();
                    map1.Layers.Add(markerLayer);
                }


                MarkerCounter++;

                MapOverlay oneMarker = new MapOverlay();
                oneMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1));

                Ellipse Circhegraphic = new Ellipse();
                Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow);
                Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
                Circhegraphic.StrokeThickness = 10;
                Circhegraphic.Opacity = 0.8;
                Circhegraphic.Height = 30;
                Circhegraphic.Width = 30;

                oneMarker.Content = Circhegraphic;

                oneMarker.PositionOrigin = new Point(0.5, 0.5);
                Circhegraphic.MouseLeftButtonDown += Circhegraphic_MouseLeftButtonDown;
                Circhegraphic.MouseLeftButtonUp += Circhegraphic_MouseLeftButtonUp;

                markerLayer.Add(oneMarker);

                if (dynamicPolyline == null) // create polyline if it does not exists yet
                {
                    dynamicPolyline = new MapPolyline();
                    dynamicPolyline.StrokeColor = Color.FromArgb(0x80, 0xFF, 0x00, 0x00);
                    dynamicPolyline.StrokeThickness = 5;

                    dynamicPolyline.Path = new GeoCoordinateCollection() { 
                            map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1))
                        };

                    map1.MapElements.Add(dynamicPolyline);
                }
                else // just add points to polyline here
                {
                    dynamicPolyline.Path.Add(map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1)));
                }
            }
            addPoint = false;
            markerSelected = false;
        }
开发者ID:ZubaerNaseem,项目名称:maps-samples,代码行数:55,代码来源:MainPage.xaml.cs

示例13: Favorites

        public Favorites()
        {
            InitializeComponent();
            LoadWatcher();
            map1.LogoVisibility = Visibility.Collapsed;
            map1.CopyrightVisibility = Visibility.Collapsed;
            map1.Mode = new AerialMode();
            map1.ZoomLevel = 5;
            map1.ZoomBarVisibility = System.Windows.Visibility.Visible;

            var settings = IsolatedStorageSettings.ApplicationSettings;
            if (settings.Contains("favorites"))
            {
                var location = settings["favorites"].ToString();
                latitude = double.Parse(location.Substring(0, location.IndexOf(",") - 1));
                longtitude =  double.Parse(location.Substring(location.IndexOf(",") + 1));
                var locationsList = new LocationCollection();
                //locationsList.Add(new GeoCoordinate(56.5845698,40.5489514));
                //locationsList.Add(new GeoCoordinate(60.4885213, 80.785426));
                locationsList.Add(new GeoCoordinate(latitude,longtitude));
                locationsList.Add(new GeoCoordinate(latitude+0.85412, longtitude+0.12564));
                MapPolyline polyline = new MapPolyline();
                polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
                polyline.StrokeThickness = 5;
                polyline.Opacity = 0.8;
                polyline.Locations = locationsList;

                //Pushpin pin = new Pushpin();

                //MessageBox.Show(location.Substring(0, location.IndexOf(",") - 1) + " \n  " + location.Substring(location.IndexOf(",") + 1));
                ////---set the location for the pushpin---
                //pin.Location = new GeoCoordinate(double.Parse(location.Substring(0, location.IndexOf(",") - 1)), double.Parse(location.Substring(location.IndexOf(",") + 1)));
                //pin.Name = "tmp";

                ////---add the pushpin to the map---

                //pin.Content = new Ellipse()
                //{
                //    //Fill = image,

                //    StrokeThickness = 10,
                //    Height = 100,
                //    Width = 100
                //};
                //pin.MouseLeftButtonUp += new MouseButtonEventHandler(Pushpin_MouseLeftButtonUp);

                //---add the pushpin to the map---
                map1.Children.Add(polyline);

                MessageBox.Show(location.ToString());
            }

            // settings["myemail"] = "[email protected]";
        }
开发者ID:marcin-owoc,项目名称:TouristGuide,代码行数:54,代码来源:Favorites.xaml.cs

示例14: InitializePolyLineOnMap

    private void InitializePolyLineOnMap()
    {
      _polyline = new MapPolyline
      {
        Path = new GeoCoordinateCollection(),
        StrokeColor = Colors.Red,
        StrokeThickness = 3
      };

      Map.MapElements.Add(_polyline);
    }
开发者ID:GregOnNet,项目名称:WP8BookSamples,代码行数:11,代码来源:MainPage.xaml.cs

示例15: BuildPoints

        private void BuildPoints(MapPolyline polyline)
        {
            for (int i = 0; i < polyline.Points.Count; i++)
            {
                MapPinPoint pinPoint = new MapPinPoint();
                pinPoint.ImageSource = new BitmapImage(new Uri(@"/Resources/point_small.png", UriKind.RelativeOrAbsolute));
                MapLayer.SetLocation(pinPoint, polyline.Points[i]);
                this.pointLayer.Items.Add(pinPoint);
                this.AttachMouseEvents(pinPoint);

            }
        }
开发者ID:jigjosh,项目名称:xaml-sdk,代码行数:12,代码来源:MainWindow.xaml.cs


注:本文中的MapPolyline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。