首页 > 解决方案 > 无法从 System.Collections.Generic.List 转换到 System.Collections.Generic.List

问题描述

我在 WPF 应用程序中使用 GMaps.NET 和 GMaps.WindowsPresentation。GMaps 演示文稿附带的类之一是 GMapPolygon 和一个名为 CreatePath 的函数。我正在尝试使用此函数测试在两个或多个点之间添加一条线,但在解析点列表时出现错误。它必须是某种类型的列表还是我错过了什么。

在使用 Windows 演示文稿时,我找不到在两点之间绘制一条线的示例,但有用于 Windows 窗体的示例

这就是我现在想要做的:

 List<PointLatLng> points = new List<PointLatLng>();
            points.Add(new PointLatLng(48.866383, 2.323575));
            points.Add(new PointLatLng(48.863868, 2.321554));
            points.Add(new PointLatLng(48.861017, 2.330030));
            points.Add(new PointLatLng(48.863727, 2.331918));
            GMapPolygon SectorPolygon = new GMapPolygon(points);
            SectorPolygon.CreatePath( points,true);

这是我要解析的函数:

public virtual Path CreatePath(List<Point> localPath, bool addBlurEffect)
      {
         // Create a StreamGeometry to use to specify myPath.
         StreamGeometry geometry = new StreamGeometry();

         using(StreamGeometryContext ctx = geometry.Open())
         {
            ctx.BeginFigure(localPath[0], true, true);

            // Draw a line to the next specified point.
            ctx.PolyLineTo(localPath, true, true);
         }

         // Freeze the geometry (make it unmodifiable)
         // for additional performance benefits.
         geometry.Freeze();

         // Create a path to draw a geometry with.
         Path myPath = new Path();
         {
            // Specify the shape of the Path using the StreamGeometry.
            myPath.Data = geometry;

            if(addBlurEffect)
            {
               BlurEffect ef = new BlurEffect();
               {
                  ef.KernelType = KernelType.Gaussian;
                  ef.Radius = 3.0;
                  ef.RenderingBias = RenderingBias.Performance;
               }

               myPath.Effect = ef;
            }

            myPath.Stroke = Brushes.MidnightBlue;
            myPath.StrokeThickness = 5;
            myPath.StrokeLineJoin = PenLineJoin.Round;
            myPath.StrokeStartLineCap = PenLineCap.Triangle;
            myPath.StrokeEndLineCap = PenLineCap.Square;

            myPath.Fill = Brushes.AliceBlue;

            myPath.Opacity = 0.6;
            myPath.IsHitTestVisible = false;
         }
         return myPath;
      }

标签: c#gmap.net

解决方案


推荐阅读