几何对象图层。主要用于在地图上添加点、线、面等。
Inheritance: SuperMap.Connector.Control.Utility.Layer
 private void btnTestGraphicsLayer_Click(object sender, EventArgs e)
 {
     Marker marker = new Marker("1", new SuperMap.Connector.Utility.Point2D(80, 30), MarkerType.Arrow, null);
     GraphicsLayer layer = new GraphicsLayer("2", "高亮");
     layer.Markers.Add(marker);
     this.mapControl1.GraphicsLayers.Add(layer);
 }
 private void AddMarker(GraphicsLayer graphicsLayer, GMapOverlay overlay, IList<Marker> items)
 {
     if (graphicsLayer == null || overlay == null) return;
     if (items == null && items.Count <= 0) return;
     if (!_markerMapGMapMarker.ContainsKey(graphicsLayer.ID))
     {
         _markerMapGMapMarker.Add(graphicsLayer.ID, new Dictionary<string, MarkerMapGMapMaker>());
     }
     foreach (Marker item in items)
     {
         if (item != null)
         {
             if (_markerMapGMapMarker[graphicsLayer.ID].ContainsKey(item.ID))
             {
                 graphicsLayer.Markers.Remove(item);
             }
             GMarkerGoogle gMarker ;
             if(item.Image!=null)
             {
                 gMarker = new GMarkerGoogle(Helper.Point2D2PointLatLng(item.Point2D), item.Image);
             }
             else
             {
                 gMarker = new GMarkerGoogle(Helper.Point2D2PointLatLng(item.Point2D), (GMarkerGoogleType)item.MarkerType);
             }
             gMarker.IsHitTestVisible = true;
             gMarker.IsVisible = true;
             overlay.Markers.Add(gMarker);
             _markerMapGMapMarker[graphicsLayer.ID].Add(item.ID, new MarkerMapGMapMaker(item, gMarker));
         }
     }
 }
 private void AddLine(GraphicsLayer graphicsLayer, GMapOverlay overlay, IList<Line> items)
 {
     if (graphicsLayer == null || overlay == null) return;
     if (items == null && items.Count <= 0) return;
     if (!_lineMapGMapRoute.ContainsKey(graphicsLayer.ID))
     {
         _lineMapGMapRoute.Add(graphicsLayer.ID, new Dictionary<string, LineMapGMapRoute>());
     }
     foreach (Line lineItem in items)
     {
         if (lineItem != null)
         {
             if (_lineMapGMapRoute[graphicsLayer.ID].ContainsKey(lineItem.ID))
             {
                 graphicsLayer.Lines.Remove(lineItem);
             }
             GMapRoute route = new GMapRoute(Helper.Point2Ds2PointLatLngs(lineItem.Point2Ds), lineItem.ID);
             route.IsHitTestVisible = true;
             route.IsVisible = true;
             route.Stroke = new Pen(lineItem.StrokeColor, (float)lineItem.StrokeWeight);
             overlay.Routes.Add(route);
             _lineMapGMapRoute[graphicsLayer.ID].Add(lineItem.ID, new LineMapGMapRoute(lineItem, route));
         }
     }
 }
        public override void OnLoad(MapControl mapControl)
        {
            base.OnLoad(mapControl);
            this.ActionDescription = "点选删除";
            if (_layer == null)
            {
                _layer = new GraphicsLayer(Guid.NewGuid().ToString(), "DelByPointActionLayer");

            }
            this.ServiceUrl = ((MapLayer)mapControl.MapLayer).ServiceUrl;
            this._mapName = ((MapLayer)mapControl.MapLayer).MapName;
            if (!mapControl.GraphicsLayers.Contains(_layer, new LayerComparer()))
            {
                mapControl.GraphicsLayers.Add(_layer);
            }
        }
        public override void OnLoad(MapControl mapControl)
        {
            base.OnLoad(mapControl);
            this.ActionDescription = "矩形圈选删除";
            if (_layer == null)
            {
                _layer = new GraphicsLayer(Guid.NewGuid().ToString(), "DelByRectActionLayer");

            }
            this.ServiceUrl = ((MapLayer)mapControl.MapLayer).ServiceUrl;
            this._mapName = ((MapLayer)mapControl.MapLayer).MapName;
            if (!mapControl.GraphicsLayers.Contains(_layer, new LayerComparer()))
            {
                mapControl.GraphicsLayers.Add(_layer);
            }
            if (_rect == null)
            {
                _rect = new Polygon(Guid.NewGuid().ToString(), new List<Point2D>(), Draw.Color.FromArgb(100, 0, 0, 255), Draw.Color.FromArgb(255, 0, 0, 255), 1);
            }
        }
        public static List<Polygon> CreatePolygon(GraphicsLayer graLayer, Feature feature, UGCLayer layer, Recordset recordset, Draw.Color fillColor, Draw.Color strokeColor)
        {
            int index = 0;
            List<Polygon> list = new List<Polygon>();
            int all = feature.Geometry.Parts.Sum();
            for (int i = 0; i < feature.Geometry.Parts.Length; i++)
            {
                Point2D[] points = feature.Geometry.Points.Skip(index).Take(feature.Geometry.Parts[i]).ToArray();
                Polygon polygon = new Polygon(feature.Id.ToString() + "@" + layer.DatasetInfo.Name + "@" + layer.DatasetInfo.DataSourceName + "@" + i.ToString(), points.ToList(), fillColor, strokeColor, 1);
                Dictionary<string, string> property = new Dictionary<string, string>();
                property[PropertyName.LayerName] = recordset.DatasetName;
                property[PropertyName.GraphicsLayerID] = graLayer.ID;
                property[PropertyName.SMID] = feature.Id.ToString();
                polygon.Tag = property;
                graLayer.Polygons.Add(polygon);
                list.Add(polygon);
                index += feature.Geometry.Parts[i];
            }

            return list;
        }
        public static void NormalResult(GraphicsLayer graLayer, QueryResult result)
        {
            if (result != null && result.Recordsets != null && result.Recordsets.Length > 0)
            {
                foreach (var v in result.Recordsets)
                {
                    if (v != null && v.Features != null && v.Features.Length > 0)
                    {
                        UGCLayer layer = QuerySetting.Layers.Cast<UGCLayer>().FirstOrDefault(c => c.Name == v.DatasetName);
                        if (layer == null)
                        {
                            continue;
                        }

                        foreach (var w in v.Features)
                        {
                            if (w == null || w.Geometry == null)
                            {
                                continue;
                            }
                            if (w.Geometry.Type == GeometryType.POINT || w.Geometry.Type == GeometryType.TEXT)
                            {
                                HelpGeometry.CreateMarker(graLayer, w, layer, v, MarkerType.Red_Pushpin);
                            }
                            else if (w.Geometry.Type == GeometryType.LINE)
                            {
                                HelpGeometry.CreateLine(graLayer, w, layer, v, Draw.Color.Blue);
                            }
                            else if (w.Geometry.Type == GeometryType.REGION || w.Geometry.Type == GeometryType.RECTANGLE)
                            {
                                HelpGeometry.CreatePolygon(graLayer, w, layer, v, Draw.Color.FromArgb(100, 0, 122, 122), Draw.Color.FromArgb(255, 0, 122, 122));

                            }
                        }
                    }
                }
            }
        }
        public static Marker CreateMarker(GraphicsLayer graLayer, Feature feature, UGCLayer layer, Recordset recordset, MarkerType type)
        {
            Marker marker = new Marker(
                                    feature.Id.ToString() + "@" + layer.DatasetInfo.Name + "@" + layer.DatasetInfo.DataSourceName + "@" + "0", feature.Geometry.Points[0], type,
                                    new SuperMap.Connector.Control.Forms.ToolTip(feature.Id.ToString(),
                                        new Draw.Font(Draw.FontFamily.Families.First(c => c.Name == "微软雅黑"), 12),
                                        Draw.StringFormat.GenericDefault, Draw.Color.White, Draw.Color.Black,
                                        Draw.Color.Black, 1));
            Dictionary<string, string> property = new Dictionary<string, string>();
            property[PropertyName.LayerName] = recordset.DatasetName;
            property[PropertyName.GraphicsLayerID] = graLayer.ID;
            property[PropertyName.SMID] = feature.Id.ToString();
            marker.Tag = property;
            graLayer.Markers.Add(marker);

            return marker;
        }
        public static Line CreateLine(GraphicsLayer graLayer, Feature feature, UGCLayer layer, Recordset recordset, Draw.Color color)
        {
            Line line = new Line(feature.Id.ToString() + "@" + layer.DatasetInfo.Name + "@" + layer.DatasetInfo.DataSourceName + "@" + "0", feature.Geometry.Points.ToList(), 2.0, color);
            Dictionary<string, string> property = new Dictionary<string, string>();
            property[PropertyName.LayerName] = recordset.DatasetName;
            property[PropertyName.GraphicsLayerID] = graLayer.ID;
            property[PropertyName.SMID] = feature.Id.ToString();
            line.Tag = property;
            graLayer.Lines.Add(line);

            return line;
        }
 public static void ClearLayer(GraphicsLayer layer)
 {
     if (layer.Lines.Count > 0)
     {
         layer.Lines.Clear();
     }
     if (layer.Markers.Count > 0)
     {
         layer.Markers.Clear();
     }
     if (layer.Polygons.Count > 0)
     {
         layer.Polygons.Clear();
     }
 }
        public override void OnLoad(MapControl mapControl)
        {
            base.OnLoad(mapControl);
            this.ActionDescription = "画多边形";
            if (_layer == null)
            {
                _layer = new GraphicsLayer(Guid.NewGuid().ToString(), "QueryByPolygonActionLayer");

            }
            this.ServiceUrl = ((MapLayer)mapControl.MapLayer).ServiceUrl;
            this._mapName = ((MapLayer)mapControl.MapLayer).MapName;
            if (!mapControl.GraphicsLayers.Contains(_layer, new LayerComparer()))
            {
                mapControl.GraphicsLayers.Add(_layer);
            }
            if (_polygon == null)
            {
                _polygon = new Polygon(Guid.NewGuid().ToString(), new List<Point2D>(), Draw.Color.FromArgb(100, 0, 0, 255), Draw.Color.FromArgb(255, 0, 0, 255), 1);
            }
            if (_points == null)
            {
                _points = new List<Point2D>();
            }
            _resultForm.MapControl = mapControl;
        }
        public override void OnLoad(MapControl mapControl)
        {
            base.OnLoad(mapControl);
            this.ActionDescription = "距离量算";
            if (_layer == null)
            {
                _layer = new GraphicsLayer(Guid.NewGuid().ToString(), "MeasureDistanceActionLayer");

            }
            this.ServiceUrl = ((MapLayer)mapControl.MapLayer).ServiceUrl;
            this._mapName = ((MapLayer)mapControl.MapLayer).MapName;
            if (!mapControl.GraphicsLayers.Contains(_layer, new LayerComparer()))
            {
                mapControl.GraphicsLayers.Add(_layer);
            }
            if (_line == null)
            {
                _line = new Line(Guid.NewGuid().ToString(), new List<Point2D>(), 1, Draw.Color.FromArgb(255, 0, 0, 255));
            }
            if (_points == null)
            {
                _points = new List<Point2D>();
            }
        }