GMap.Net 在 winform 中开发 改变多边形着色
参考资料
[](https://www.cnblogs.com/sethnie/p/15856122.html)
[GMap.Net 在 winform 中开发 绘制多边形和轨迹](https://www.cnblogs.com/sethnie/p/15856131.html)
绘制多边形并着色
// 添加多边形节点 Listpoints = 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)); //绘制多边形用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);
改变着色
////// 改变 Polygons 填充颜色 /// /// Polygons 名称 /// Polygons 填充颜色 void changePolygonsColor(String name,Color color) { for (int i = 0; i < gMapControl.Overlays.Count; i++) { for (int j = 0; j < gMapControl.Overlays[i].Polygons.Count; j++) { if (gMapControl.Overlays[i].Polygons[j].Name == name) { gMapControl.Overlays[i].Polygons[j].Fill = new SolidBrush(Color.FromArgb(50, color)); } } } }