『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

MapGIS 10 Objcet开发入门(4-6) MapGIS 10 Objects开发常见问题之显示部分动态注记

MapGIS 10 Objcet开发入门(4-6) MapGIS 10 Objects开发常见问题之显示部分动态注记
答:这个问题涉及到两个方面:动态注记与部分显示。

    答:这个问题涉及到两个方面:动态注记与部分显示。

 

     在 GeoMap 提供的图层对象(VectorLayer)里面都有相应的功能接口与之对应,动态注记由图层的属性 Label 提供;而实现部分显示则通过图层设置显示过滤条件,由函数 SetDispCondition 提供。示例代码如下:

 

   //地图显示控件

    MapControl mapControl1 = null;

    //数据库服务器

    Server srv = null;

    //数据库

    DataBase db = null;

    //数据

    SFeatureCls SFeature = null;

    Map map = null;

    VectorLayer layer = null;

     //初始化控件

    this.mapControl1 = new MapControl();

    this.splitContainer1.Panel2.Controls.Add(this.mapControl1);

    //打开数据源

    srv = new Server();

    srv.Connect("mapgislocal", "", "");

    db = srv.OpenGDB("world");

    //打开用于显示的简单要素类

     SFeature = (SFeatureCls)db.GetXClass(XClsType.SFCls);

    SFeature.Open("行政区.WP", 0);

    layer = new VectorLayer(VectorLayerType.SFclsLayer);

    if (SFeature != null)

layer.AttachData(SFeature);

//添加图层

map = new Map();

map.Append(layer);

//显示图层

this.mapControl1.ActiveMap = map;

SimpleLabel splbl = null;

//注记信息

LabelInfo labelInfo = null;

//注记图形信息

AnnInfo annInfo = null;

//区标注分布信息

RegionPlaceInfo regPlaceInfo = null;

splbl = new SimpleLabel();

labelInfo = new LabelInfo();

TextAnnInfo txtAnninfo = new TextAnnInfo();

regPlaceInfo = new RegionPlaceInfo();

#region 设置注记图形信息

txtAnninfo.Color = 5;

txtAnninfo.Height = 10;

txtAnninfo.Width = 10;

//间隔

txtAnninfo.Space = 2;

//压盖

txtAnninfo.Ovprnt = true;

#endregion

#region 设置注记显示参数信息

labelInfo.AnnInfo = txtAnninfo;

labelInfo.Caption = "名称";

labelInfo.IsVisible = true;

labelInfo.MaxScale = 0;

labelInfo.MinScale = 0;

#endregion

#region 区标注分布信息

//每个要素一个标注

regPlaceInfo.DuplicateType = DuplicateType.OneLabelPreFeature;

//自适应

regPlaceInfo.LimitLabelSmallRegion = true;

//最大面积

regPlaceInfo.SmallRegionMaxArea = 500;

//可标注在区外

regPlaceInfo.TryLabelOutside = true;

//区方位-水平标注

regPlaceInfo.Type = RegPlaceType.HorizationPlace;

#endregion

#region 设置简单注记

//设置属性字段*

splbl.LabelExpression = "名称";

splbl.HighlightClr = 6;

splbl.LabelGeomType = LabelGeomType.RegionGeom;

//设置区标注分布

splbl.RegPlaceInfo = regPlaceInfo;

//高亮显示未能标注的注记

splbl.HighlightLabelUnPlaced = true;

splbl.LabelUnPlaced = true;

splbl.Priority = 1;

//显示动态注记

splbl.Visible = true;

splbl.SetInfo(labelInfo);

#endregion

//初始化条件显示条件

MapGIS.GeoDataBase.QueryDef disCondition = new QueryDef();

disCondition.Filter="ID>5";

disCondition.CursorType = SetCursorType.ForwardBackward;

//设置条件显示

layer.SetDispCondition(disCondition);

//设置动态注记

layer.Label = splbl;

this.mapControl1.Refresh();

      京ICP备08100627号-22 京公网安备 11010802030428号