Select to view content in your preferred language

Force map labels horizontal

208
2
Jump to solution
a month ago
MariusN
New Contributor II

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

 

 

 

rotation.png

 

 

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

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

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

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

0 Kudos
MariusN
New Contributor II

Works!

Will look into the viewer 👍

0 Kudos