コード例 #1
0
        /// <summary>
        /// 向制定名称的绘制图层添加一个绘制对象
        /// </summary>
        /// <param name="gra">绘制对象</param>
        /// <param name="target">绘制图层名称</param>
        /// <param name="param">参数</param>
        public void AddGraphic(Graphic gra, string target, object param = null)
        {
            switch (target)
            {
            case "Highlight":
                //if (gra.Geometry is MapPoint)
                //{
                //    SimpleMarkerSymbol s = new SimpleMarkerSymbol
                //    {
                //        Color = Color.FromArgb(0, 0, 0, 0),
                //        Size = 20,
                //        Outline =
                //            new SimpleLineSymbol { Color = Colors.Red, Style = SimpleLineStyle.Solid, Width = 3 }
                //    };
                //    gra.Symbol = s;
                //}
                if (gra.Geometry is MapPoint)
                {
                    var bytes = param as byte[];
                    if (bytes != null)
                    {
                        var ps = new PictureMarkerSymbol();
                        ps.SetSource(bytes);
                        gra.Symbol = ps;
                    }
                }
                _highLightLayer.Graphics.Add(gra);
                break;

            case "Drawing":
                if (gra.Geometry is MapPoint)
                {
                    var bytes = param as byte[];
                    if (bytes != null)
                    {
                        var ps = new PictureMarkerSymbol();
                        ps.SetSource(bytes);
                        gra.Symbol = ps;
                    }
                }
                if (gra.Geometry is Polyline)
                {
                    if (param == null)
                    {
                    }
                    else
                    {
                        SimpleLineSymbol sls = new SimpleLineSymbol
                        {
                            Color = Colors.Red,
                            Width = 5
                        };
                        gra.Symbol = sls;
                    }
                }
                _drawingLayer.Graphics.Add(gra);
                break;
            }
        }