- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
先简单讲讲mask out,所谓Mask out就是屏蔽某些区域之外的图形。MapView有个MaskOut属性,可以设置SetMaskOut和MaskLayer(必须是Polygon图层,不要太复杂)。
- private void TSMI_Maskout_Click(object sender, EventArgs e)
- {
- layersLegend1.ActiveMapFrame.MapView.MaskOut.SetMaskLayer = true;
- layersLegend1.ActiveMapFrame.MapView.MaskOut.MaskLayer = "china.shp";
- layersLegend1.ActiveMapFrame.MapView.PaintLayers();
- }
复制代码
Mask out之前:
Mask out之后:
再讲讲创建点图层。创建一个VectorLayer图层需要给图层对象增加属性字段,并添加相应的Shape对象及属性值。详见下面的示例程序:
- private void TSMI_CreatePointLayer_Click(object sender, EventArgs e)
- {
- //New layer
- VectorLayer aLayer = new VectorLayer(ShapeTypes.Point);
- aLayer.LayerName = "New_Point_Layer";
- aLayer.LegendScheme = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Black, 10);
- //aLayer.LegendScheme.breakList[0].Color = Color.Blue;
- aLayer.Visible = true;
- //Add fields
- aLayer.EditAddField("STATION", typeof(string));
- aLayer.EditAddField("LON", typeof(double));
- aLayer.EditAddField("LAT", typeof(double));
- aLayer.EditAddField("DATA", typeof(double));
- //Prepare coordinate data
- double[] X = new double[2] { 120.0, 110.0 };
- double[] Y = new double[2] { 42.0, 35.0 };
- double[] data = new double[2] { 100.0, 80.0 };
- //Add shape
- for (int i = 0; i < 2; i++)
- {
- PointShape aPS = new PointShape();
- PointD aPoint = new PointD();
- aPoint.X = X[i];
- aPoint.Y = Y[i];
- aPS.Point = aPoint;
- int shapeNum = aLayer.ShapeNum;
- if (aLayer.EditInsertShape(aPS, shapeNum))
- {
- //Edit record value
- aLayer.EditCellValue("STATION", shapeNum, "St1");
- aLayer.EditCellValue("LON", shapeNum, aPoint.X);
- aLayer.EditCellValue("LAT", shapeNum, aPoint.Y);
- aLayer.EditCellValue("DATA", shapeNum, data[i]);
- }
- }
- //Add Label
- aLayer.LabelSet.FieldName = "DATA";
- aLayer.LabelSet.LabelFont = new Font("Arial", 15);
- aLayer.LabelSet.YOffset = 30;
- aLayer.AddLabels();
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MapView.PaintLayers();
- layersLegend1.Refresh();
- }
复制代码
效果如下:
|
|