Labels not showing on polygon

725
2
Jump to solution
12-30-2021 05:57 AM
Moer
by
New Contributor

(UWP, 100.12 & 100.13)

Some polygons don't display the label that is specified on the overlay.

I have extracted some code to a demo project that shows the problem. I have added three polygons to an overlay and added a symbol renderer and a label definition. The large polygon doesn't show the label.

 

Moer_0-1640872260233.png

Code extract (see full demo in attached zip):

            testLayer = new GraphicsOverlay
            {
                Id = "TEST_LAYER",
                RenderingMode = GraphicsRenderingMode.Static,
                LabelsEnabled = true,
            };

            //Symbol renderer
            testLayer.Renderer = new SimpleRenderer(new SimpleLineSymbol
            {
                Color = Color.Yellow,
                Style = SimpleLineSymbolStyle.Solid,
                Width = 2
            });

            //Label def
            var label = new LabelDefinition(new SimpleLabelExpression($"\"Test\""), new TextSymbol
            {
                BackgroundColor = Color.Aqua,
                Color = Color.Black,
                Size = 14
            });

  

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
TonyWakim
Esri Contributor

Calling "poly = GeometryEngine.Simplify(poly);" on your polygon before adding it to the GraphicsOverlay should resolve the issue.

 

 

        private void addPolygon(string polygonJson)
        {
            var poly = Geometry.FromJson(polygonJson);

            poly = GeometryEngine.Simplify(poly);
            var graphic = new Graphic
            {
                Geometry = GeometryEngine.Project((Polygon)poly, new SpatialReference(3006))
            };
            testLayer.Graphics.Add(graphic);
        }

 

TonyWakim_0-1641323944524.png

 

 

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Have you checked that your geometries are OK? An invalid geometry will display on the map but won't show a label. If this is what's wrong, running the RepairGeometries tool should solve it.

https://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/check-geometry.htm 

https://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/repair-geometry.htm 


Have a great day!
Johannes
0 Kudos
TonyWakim
Esri Contributor

Calling "poly = GeometryEngine.Simplify(poly);" on your polygon before adding it to the GraphicsOverlay should resolve the issue.

 

 

        private void addPolygon(string polygonJson)
        {
            var poly = Geometry.FromJson(polygonJson);

            poly = GeometryEngine.Simplify(poly);
            var graphic = new Graphic
            {
                Geometry = GeometryEngine.Project((Polygon)poly, new SpatialReference(3006))
            };
            testLayer.Graphics.Add(graphic);
        }

 

TonyWakim_0-1641323944524.png

 

 

0 Kudos