首页 > 其他 > 详细

ArcGIS Pro二次开发-图层标注

时间:2020-03-14 15:45:29      阅读:116      评论:0      收藏:0      [点我收藏+]
 if (MapView.Active.GetSelectedLayers().Count != 1)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("One feature layer must be selected in the Contents pane. Exiting...", "Info");
                return;
            }

            var lyr = MapView.Active.GetSelectedLayers().First() as FeatureLayer;


            if (lyr == null) return;
            QueuedTask.Run(() =>
            {
                //Get the layer‘s definition
                //community sample Data\Admin\AdminSample.aprx
                var lyrDefn = lyr.GetDefinition() as CIMFeatureLayer;
                if (lyrDefn == null) return;
                //Get the label classes - we need the first one
                var listLabelClasses = lyrDefn.LabelClasses.ToList();
                var theLabelClass = listLabelClasses.FirstOrDefault();
                //set the label class Expression to use the Arcade expression
                theLabelClass.Expression = "return $feature.gisoracleid + TextFormatting.NewLine + $feature.objectid;";
                //Set the label definition back to the layer.
                lyr.SetDefinition(lyrDefn);
                lyr.SetLabelVisibility(true);
            });

 

ArcGIS Pro二次开发-图层标注

原文:https://www.cnblogs.com/gisoracle/p/12492226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!