Hi All
Hi All
I am working to implement an annotation tool,Click the button to display all annotations.Why do I use this code to create annotations, but when the program runs it shows blank space?Am i missing something?
(c sharp code)
CIMLabelClass labelClass = new CIMLabelClass
{Visibility = true };
labelClasses.Add(labelClass);
layerDef.LabelClasses = labelClasses.ToArray();
layerDef.LabelVisibility = true;
layer.SetDefinition(layerDef);
mapView.Redraw(true);
Thanks!
rs
Hi,
Annotation layers haven't labels. Showing of annotations is organized with sublayers.
CIMAnnotationLayer Sublayers property is array of CIMAnnotationSubLayer.
I'm sorry I made a mistake.I want to display multiple groups of labels that I have set.Thank you.
I think that you need to set TextSymbol property for your created labelClass.
// Blue label
CIMLabelClass blueLabelClass = new CIMLabelClass
{
Name = "Blue",
ExpressionTitle = "Expression-Blue",
ExpressionEngine = LabelExpressionEngine.Arcade,
Expression = "$feature.OBJECTID",
ID = 2,
Priority = 0,
Visibility = true,
TextSymbol = new CIMSymbolReference
{
Symbol = new CIMTextSymbol()
{
Angle = 45,
FontType = FontType.Type1,
FontFamilyName = "Consolas",
FontEffects = FontEffects.Normal,
HaloSize = 2.0,
Symbol = new CIMPolygonSymbol
{
SymbolLayers = new CIMSymbolLayer[]
{
new CIMSolidFill
{
Color = CIMColor.CreateRGBColor(0, 0, 255)
}
},
UseRealWorldSymbolSizes = true
}
},
MaxScale = 0,
MinScale = 0,
SymbolName = "TextSymbol-Blue"
},
StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
{
AllowOverlappingLabels = true,
LineOffset = 1.0
},
MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
{
AlignLabelToLineDirection = true,
AvoidPolygonHoles = true
}
};
I've created several tag classes.After the code is run, tag classes are generated,but it doesn't show.However, without changing any parameters, manually operate ArcGIS pro, click the Apply button, the label will be displayed.
Thanks.
CIMLabelClass labelClass = new CIMLabelClass
{
Name = $"LabelClass_{value}",
Expression = "$feature.Label",
ExpressionEngine = LabelExpressionEngine.Arcade,
Priority = 0,
Visibility = true,
WhereClause = $"Label = '{river}'",
TextSymbol = SymbolFactory.Instance.ConstructTextSymbol(color, 15, "Arial").MakeSymbolReference(),
};
labelClasses.Add(labelClass);
var layerDef = featureLayer.GetDefinition() as CIMFeatureLayer;
layerDef.LabelClasses = labelClasses.ToArray();
featureLayer.SetDefinition(layerDef);
featureLayer.SetLabelVisibility(true);
mapView.Redraw(true);
Try to put mapView.Redraw(true); in another QueuedTask.Run. Sometimes separating MCT threads helps.
Or use RedrawAsync method outside QueuedTask.Run which doesn't need MCT thread.
Okay, I tried it. The problem still persists. I will try other methods. Thank you for your reply many times.