I would like to render a circular graphic symbol, but with text inside the circle. For a simple example, I have the following class break example where I would like to set text inside the circle:
ClassBreakInfo {
minimum: 11.9
maximum: 12.1
symbol: SimpleMarkerSymbol {
color: "limegreen"
size: 2
}
}
Is there a way to add text to a SimpleMarkerSymbol. I see there isn't a property for text. Is there a way to composite SimpleMarkerSymbol and TextSymbol that I can bind to 'symbol:' ?
Thanks.
Solved! Go to Solution.
Ranier,
No, many class breaks for many text strings is not what I had in mind. Rather, I was thinking of static text for each class break, such as "small", "medium" and "large". This would be an unusual scenario.
As you have noted, there is no built-in provision for adding label text to a class break renderer's symbols. If you were displaying features from a dynamic map service, you could label features in various ways using DynamicLayerInfo.DrawingInfo.LabelingInfo.
The best you can do with graphics now is to display two co-located graphics per feature, one a marker symbol and another a text symbol built using an attribute from the graphic.
Ranier,
Question: Would your text be static or supplied from an attribute or other dynamic source?
Thanks.
Thomas,
That's a good question. If the text is static, then I would need a good number of ClassBreakInfo components - one for each unique text case!? If the text is set as an attribute then that would reduce the number of ClassBreakInfo components that I would need. Once the text is set for the graphic, it won't change for the life of the graphic.
So my answer is: it depends. I would be interested in hearing both solutions (if they exist) for the static and dynamic case.
Thanks.
-Rainer
Ranier,
No, many class breaks for many text strings is not what I had in mind. Rather, I was thinking of static text for each class break, such as "small", "medium" and "large". This would be an unusual scenario.
As you have noted, there is no built-in provision for adding label text to a class break renderer's symbols. If you were displaying features from a dynamic map service, you could label features in various ways using DynamicLayerInfo.DrawingInfo.LabelingInfo.
The best you can do with graphics now is to display two co-located graphics per feature, one a marker symbol and another a text symbol built using an attribute from the graphic.
Thomas,
Thanks. Here's a related question. Is it possible to change the color of a symbol based on a graphic's attribute given that a SimpleRenderer is used? Using sample code from ArcGIS Runtime SDK for Qt QML API: SimpleRenderer Class Reference (below), is it possible to use JS for the 'color:' binding to select color based on a graphic's attribute, or do I need to use a ClassBreakRender?
GraphicsLayer {
id: graphicsLayer
renderer: simple
}
SimpleRenderer {
id: simple
symbol: SimpleFillSymbol {
style: Enums.SimpleFillSymbolStyleForwardDiagonal
color: "#9050d5"
outline: SimpleLineSymbol {
color: "darkgrey"
width: 1
}
}
}
Ranier,
Sorry, not through the renderer. You cannot bind the color property of a shared symbol to varying attribute values of individual graphics. You could instead create a new symbol for each graphic, where the color of the symbol is based on a graphic attribute.