You can change the way military symbols are visualized by implementing your own IFeaturePainter.

The IFeaturePainter implementation needs to:

For example, the implementation below paints icon symbols with a surrounding rectangle when they are selected, and also adds an additional label below each symbol.

class MyMilitarySymbolPainter : public IFeaturePainter {
public:
MyMilitarySymbolPainter()
// Regular symbols are painted with a default style, while selected symbols are painted with a surrounding rectangle.
: _defaultStyle(MilitarySymbolStyle::newBuilder().build()), _selectedStyle(_defaultStyle->asBuilder().surroundingRectangleEnabled(true).build()) {
}
void configureMetadata(FeaturePainterMetadata& /*metadata*/) const override {
}
void paint(const Feature& feature, const FeaturePainterContext& context, FeatureCanvas& canvas) const override {
// Retrieve the geometry from the feature
auto geometry = feature.findGeometry();
if (!geometry) {
std::cerr << "Ignoring feature '" << feature.getId() << "'. It has no geometry." << std::endl;
return;
}
// Transform the feature to a military symbol.
auto symbol = MilitarySymbol::create(feature);
// Use a MilitarySymbologyCanvas to submit a draw command for the military symbol.
// The submitted symbol style depends on whether the feature is currently selected or not.
MilitarySymbologyCanvas(canvas)
.drawMilitarySymbol()
.symbol(symbol)
.geometry(geometry)
.style(context.isFeatureStateEnabled(FeatureState::selected()) ? _selectedStyle : _defaultStyle)
.submit();
// Paint the symbol code as an additional label, with a fixed offset below the symbol.
RelativePosition labelPosition{0, HorizontalAlignment::Center, VerticalAlignment::Top, 0, _defaultStyle->getIconSize() + 50.0};
canvas.drawText().text(symbol->getCode()).position(labelPosition).anchor(geometry).submit();
}
private:
std::shared_ptr<MilitarySymbolStyle> _defaultStyle;
std::shared_ptr<MilitarySymbolStyle> _selectedStyle;
};