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);
});
}