- 积分
- 176
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-5-22
- 最后登录
- 1970-1-1
|
发表于 2013-5-28 15:31:22
|
显示全部楼层
private void CreateSLLayer(string sttp)
{
DataTable dtData =new DataTable();
dtData = dtData0.Copy();
//New layer
VectorLayer aLayer = new VectorLayer(ShapeTypes.Point);
aLayer.LayerName = "ST_" + sttp;
aLayer.LegendScheme = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Black, 10);
aLayer.LegendScheme.LegendType = LegendType.UniqueValue;
aLayer.Visible = true;
//Add fields
aLayer.EditAddField("STCD", typeof(string));
aLayer.EditAddField("LON", typeof(double));
aLayer.EditAddField("LAT", typeof(double));
aLayer.EditAddField("STNM", typeof(string));
aLayer.EditAddField("STTP", typeof(string));
//Add shape
dtData.DefaultView.RowFilter = "STTP = '" + sttp+ "'";
for (int i = 0; i < dtData.Rows.Count; i++)
{
PointShape aPS = new PointShape();
PointD aPoint = new PointD();
aPoint.X = double.Parse(dtData.Rows[i]["LGTD"].ToString());
aPoint.Y = double.Parse(dtData.Rows[i]["LTTD"].ToString());
aPS.Point = aPoint;
int shapeNum = aLayer.ShapeNum;
if (aLayer.EditInsertShape(aPS, shapeNum))
{
//Edit record value
aLayer.EditCellValue("STCD", shapeNum, dtData.Rows[i]["STCD"].ToString());
aLayer.EditCellValue("LON", shapeNum, aPoint.X);
aLayer.EditCellValue("LAT", shapeNum, aPoint.Y);
aLayer.EditCellValue("STNM", shapeNum, dtData.Rows[i]["STNM"].ToString());
aLayer.EditCellValue("STTP", shapeNum, dtData.Rows[i]["STTP"].ToString());
}
}
//Add Label
aLayer.LabelSet.FieldName = "STNM";
aLayer.LabelSet.LabelFont = new Font("Arial", 10);
aLayer.LabelSet.YOffset = -5;
aLayer.LabelSet.LabelColor = (sttp == "RR" ? Color.Green : Color.Blue);
aLayer.AddLabels();
aLayer.LegendScheme.ShapeType = ShapeTypes.Image;
foreach (PointBreak legend in aLayer.LegendScheme.LegendBreaks)
{
legend.MarkerType = MarkerType.Image;
legend.ImagePath = "images/"+sttp + ".gif";
//legend.Color = (sttp == "RR" ? Color.Blue : Color.Blue);
legend.Size = 10;
}
//Add layer
mapView1.AddLayer(aLayer);
mapView1.PaintLayers();
mapView1.Refresh();
}
这是我的代码,老师指导下咧~~ |
|