如何给等值线做标注Arcgis for sl

这篇博客展示了如何使用C#代码为等值线进行标注操作,通过遍历ShapeFileRecord并设置SimpleLineSymbol,然后利用TextSymbol添加文字信息到等值线的起点和终点,字体、颜色和大小都进行了设定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这里只给出标注部分的代码:

 

foreach (ShapeFileRecord record in shapeFileReader.Records)
                {
                    Graphic graphic = record.ToGraphic();
                    if (graphic != null)
                    {
                        int index = 0;
                        for (int i = 0; i < Config.level.Split(',').Length; i++)
                        {
                            if (graphic.Attributes["mark"].ToString() == Config.level.Split(',')[i])
                            {
                                index = i;
                                break;
                            }
                        }

                        graphic.Symbol = new SimpleLineSymbol()
                        {
                            Color = new SolidColorBrush(colors[0]),
                            Style = SimpleLineSymbol.LineStyle.Solid,
                            Width = 2
                        };

                        #region 等值线添加标注
                        ESRI.ArcGIS.Client.Geometry.Polyline pLine = graphic.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
                        ESRI.ArcGIS.Client.Geometry.PointCollection pCollection = pLine.Paths[0];

                        //添加文字信息  
                        TextSymbol textSymbol = new TextSymbol()
                        {
                            FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"),
                            Foreground = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
                            FontSize = 12,
                            Text = Config.level.Split(',')[index]
                        };

                        ESRI.ArcGIS.Client.Geometry.MapPoint mpStart = pCollection[0];
                        Graphic graphicTextStart = new Graphic()
                        {
                            Geometry = mpStart,
                            Symbol = textSymbol
                        };
                        DZXMBiaoZhuLayer.Graphics.Add(graphicTextStart);

                        ESRI.ArcGIS.Client.Geometry.MapPoint mpEnd = pCollection[pCollection.Count - 1];
                        Graphic graphicTextEnd = new Graphic()
                        {
                            Geometry = mpEnd,
                            Symbol = textSymbol
                        };
                        DZXMBiaoZhuLayer.Graphics.Add(graphicTextEnd);
                        #endregion
                    }
                    DZXMLayer.Graphics.Add(graphic);
                }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值