ArcGIS Pro C#设置图层标注权重

文摘   2024-10-27 07:55   云南  

 public static void setFeatureWeight(FeatureLayer featureLayer, int featureWeight, int boundaryWeight)
 {
     QueuedTask.Run(() =>
     {
         // 创建缩写字典并添加到地图定义

         // 获取图层的定义
         var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer;
         // 获取标签类 - 我们需要第一个
         var listLabelClasses = lyrDefn.LabelClasses.ToList();
         var theLabelClass = listLabelClasses.FirstOrDefault();
         // 修改标签放置属性以使用缩写字典
         // CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties;
         theLabelClass.MaplexLabelPlacementProperties.FeatureWeight = featureWeight;
         theLabelClass.MaplexLabelPlacementProperties.PolygonBoundaryWeight = boundaryWeight;
         theLabelClass.MaplexLabelPlacementProperties.CanStackLabel = false;
         // 重新设置标签类
         lyrDefn.LabelClasses = listLabelClasses.ToArray();
         // 设置图层的定义
         featureLayer.SetDefinition(lyrDefn);
     });
 }

GISAI
ArcGIS培训和二次开发
 最新文章