GMap.Net 在 winform 中开发 绘制多边形和轨迹


参考资料:

[](https://www.cnblogs.com/sethnie/p/15856122.html)

代码展示多边形绘制和轨迹绘制

           // 添加多边形节点
            List points = new List();
            points.Add(new PointLatLng(37.1412768409666, 79.6562057733536));
            points.Add(new PointLatLng(37.1403574434934, 79.6564793586731));
            points.Add(new PointLatLng(37.1405669815751, 79.6581155061722));
            points.Add(new PointLatLng(37.1416146632773, 79.6577936410904));
            points.Add(new PointLatLng(37.1412768409666, 79.6562057733536));
            
            //绘制折线用GMapRoute 
            GMapRoute route = new GMapRoute(points, "");
            route.Stroke = new Pen(Color.Red, 1); // 折线颜色,线宽
            polyOverlay.Routes.Add(route);

            //绘制多边形用GMapPolygon 
            GMapPolygon polygon = new GMapPolygon(points, "polygons");
            polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Green));// 配置多边形填充颜色
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gMapControl.Overlays.Add(polyOverlay);