Is there a way to force labels added to a map to appear horizontal?
return QueuedTask.Run(() =>
{
var lyr = featureLayer;
var lyrDefn = lyr.GetDefinition() as CIMFeatureLayer;
CIMTextSymbol textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 12, "Arial", "Bold");
textSymbol.Callout = CreateCIMCallout();
//Create the new label class and initialize props
var newLabelClass = new CIMLabelClass
{
ExpressionEngine = LabelExpressionEngine.Arcade,
Expression = "$feature.id",
Visibility = true,
TextSymbol = textSymbol.MakeSymbolReference(),
Name = "XX",
};
var maplexLabelPlacementProps = new CIMMaplexLabelPlacementProperties
{
ThinDuplicateLabels = true,
FeatureType = LabelFeatureType.Polygon,
};
var standardLabelPlacementProps = new CIMStandardLabelPlacementProperties
{
FeatureType = LabelFeatureType.Polygon,
};
newLabelClass.MaplexLabelPlacementProperties = maplexLabelPlacementProps;
var lyrsLabelsClasses = lyrDefn.LabelClasses.ToList();
lyrsLabelsClasses.Clear();
lyrsLabelsClasses.Add(newLabelClass);
lyrDefn.LabelClasses = lyrsLabelsClasses.ToArray(); //Set the labelClasses back
lyr.SetDefinition(lyrDefn); //set the layer's definition;
featureLayer.SetLabelVisibility(true);
});
Solved! Go to Solution.
Hi,
Set additional property to maplexLabelPlacementProps:
var maplexLabelPlacementProps = new CIMMaplexLabelPlacementProperties
{
ThinDuplicateLabels = true,
FeatureType = LabelFeatureType.Polygon,
PolygonPlacementMethod = MaplexPolygonPlacementMethod.HorizontalInPolygon
};
I would recommend you use CIM Viewer for that kind of investigation
Hi,
Set additional property to maplexLabelPlacementProps:
var maplexLabelPlacementProps = new CIMMaplexLabelPlacementProperties
{
ThinDuplicateLabels = true,
FeatureType = LabelFeatureType.Polygon,
PolygonPlacementMethod = MaplexPolygonPlacementMethod.HorizontalInPolygon
};
I would recommend you use CIM Viewer for that kind of investigation
Works!
Will look into the viewer 👍