Select to view content in your preferred language

Renderer for TextSymbol?

443
1
04-24-2023 08:10 AM
Labels (4)
noodle
by
New Contributor III

We have a json file for a noise layer which contains feature with text symbol (see below: this is the output of json where "text" value changes, e.g. 60dB, 65dB etc.).   How can I create Renderer so that I can do FeatureCollectionTable.Renderer?    Feature does not take symbol.

symbol:{
"type": "esriTS",
"__type": "TextSymbol:#ESRI.ArcGIS.Client.Symbols",
"color": [
0,
0,
0,
255
],
"text": "55dB",
"xoffset": 0,
"yoffset": 0,
"horizontalAlignment": "left",
"verticalAlignment": "top",
"font": {
"family": "Arial",
"size": 7.5,
"weight": "bold",
"style": "normal",
"decoration": "none"
}

 

Tags (2)
0 Kudos
1 Reply
noodle
by
New Contributor III

I resolved this problem.   Just create a uniquevaluerenderer and create a Feature with "text" and link to the text symbol .Text.

public static Renderer CreateTextRenderer(List<Symbol> symbolList)
{
if (symbolList.Any())
{
UniqueValueRenderer textRenderer = new UniqueValueRenderer();
textRenderer.FieldNames.Add("text");
foreach (var tSymbol in symbolList)
{
if (tSymbol is TextSymbol textSymbol)
{
string value = ((TextSymbol)tSymbol).Text;
textRenderer.UniqueValues.Add(
new UniqueValue(value, "text", tSymbol, value));
}
}

return textRenderer;
}

0 Kudos