Select to view content in your preferred language

LabelDefinition in example

370
0
03-20-2022 05:07 PM
TaylorCarnell1
Occasional Contributor

Is the initialisation of the LabelDefinition correct in the following example? (https://developers.arcgis.com/net/styles-and-data-visualization/add-labels/)

 

LabelDefinition labelDefSmall = new LabelDefinition
    {
        WhereClause = "[POPULATION] < 500000",
        TextSymbol = textSymbolSmallCities,
        Expression = new ArcadeLabelExpression("return $feature.name;"),
        // Expression = new SimpleLabelExpression("[NAME]"),
        Placement = Esri.ArcGISRuntime.ArcGISServices.LabelingPlacement.PointBelowCenter
    };

 

 

I was banging my head dealing with an error that LabelDefintion wasn't supplied the required LabelExpression parameter when, reading the documentation, I realised it should be:

 

            LabelDefinition labelDefSmall = new LabelDefinition(new ArcadeLabelExpression("return $feature.name;"), textSymbolSmallCities)
            {
                WhereClause = "[POPULATION] < 500000",
                Placement = Esri.ArcGISRuntime.ArcGISServices.LabelingPlacement.PointBelowCenter
            };

 

 

Thanks

0 Kudos
0 Replies