这里只给出标注部分的代码:
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);
}