zoukankan      html  css  js  c++  java
  • ArcGIS Engine获取单条要素的标注(LABEL)内容

    众所周知,arcgis的标注设置是对整个图层的,那有没有办法获取某条要素的标注内容呢?当然有!!!

    分两步,第一步先获取layer级别的IAnnotationExpressionParser对象,获取标注内容靠他了

     1             IAnnotationExpressionParser tAnnoExpParse = null;
     2 
     3             IAnnotateLayerPropertiesCollection tAnnotateLayerPropertiesCollection = tGeoFeatureLayer.AnnotationProperties;
     4             IAnnotateLayerProperties tAnnotateLayerProperties = null;
     5             IElementCollection tElementCollection = null;     
     6             if (tAnnotateLayerPropertiesCollection.Count > 0)
     7             {
     8                 tAnnotateLayerPropertiesCollection.QueryItem(0, out tAnnotateLayerProperties, out tElementCollection, out tElementCollection);
     9                 ILabelEngineLayerProperties tLabelEngineLayerProperties = tAnnotateLayerProperties as ILabelEngineLayerProperties;     
    10                 //获取标注解析类
    11                 IAnnotationExpressionEngine tAnnoExpEngine = tLabelEngineLayerProperties.ExpressionParser;
    12                 if (tLabelEngineLayerProperties.IsExpressionSimple == true)
    13                 {
    14                     tAnnoExpParse = tAnnoExpEngine.SetExpression("", tLabelEngineLayerProperties.Expression);
    15                 }
    16                 else
    17                 {
    18                     tAnnoExpParse = tAnnoExpEngine.SetCode(tLabelEngineLayerProperties.Expression, "");
    19                 }

    第二步相对简单,关键函数是FindLabel

    string labelValue = tAnnoExpParse.FindLabel(tFeature);

    关于这种方法还有点疑问

    首先,获取用SetExpression和SetCode这两个函数去获取IAnnotationExpressionParser感觉很怪,非得要赋值才能取值很有问题。

    其次SetExpression和SetCode这两个函数有些参数不理解,所以只是给了空值,这也是个隐患

  • 相关阅读:
    在JS中如何去掉千分号
    JS中showModalDialog详细使用
    js里的insertCell和appendChild的区别
    js showModalDialog
    js中innerHTML,innerText,outerHTML的用法和区别
    MYSQL入门指导
    对拍程序C语言实现
    人性的弱点
    POJ3207(2SAT)
    期末考试时间安排
  • 原文地址:https://www.cnblogs.com/cannel/p/2480507.html
Copyright © 2011-2022 走看看