The default Military Symbology IFeaturePainterIFeaturePainterIFeaturePainter implementations only work for feature models with the Military Symbology DataModelMilitary Symbology DataModelMilitary Symbology DataModel.

If the features in your model are not configured according to this data type, you can still visualize your data as military symbols by implementing your own painter. This is useful if you want to add your own symbols, or if your military symbols do not entirely comply with the supported military symbology standards.

The IFeaturePainterIFeaturePainterIFeaturePainter implementation needs to:

The example implementation below visualizes every feature as a fixed MIL-STD 2525b icon symbol.

class CustomMilitarySymbolPainter : public IFeaturePainter {
public:
  void configureMetadata(FeaturePainterMetadata& metadata) const override {
    // If the feature's geometry changes, the symbol needs to be painted on a different location.
    metadata.painterDependsOnFeature(true);
  }

  void paint(const Feature& feature, const FeaturePainterContext& /*context*/, FeatureCanvas& canvas) const override {
    // Create a geometry denoting the symbol's location.
    // For an icon symbol, this needs to be a point, so we use the center point of the feature geometry's bounds.
    auto featureGeometry = feature.findGeometry();
    if (!featureGeometry) {
      std::cerr << "Ignoring feature '" << feature.getId() << "'. It has no geometry." << std::endl;
      return;
    }
    auto center = featureGeometry->getBounds().getCenter();
    auto symbolGeometry = GeometryFactory::createPoint(featureGeometry->getReference(), center.x, center.y, 0);

    // Create the military symbol to visualize. You can customize the symbol based on the feature.
    // In this example, we simply set the feature ID as value for the symbol text modifier "Unique Designation".
    auto symbol = MilitarySymbol::create(MilitarySymbology::Standard::MilStd2525d, "10030100001101000000");
    symbol->putValue(MilitarySymbol::Modifier::UniqueDesignation, std::to_string(feature.getId()));

    // Use a MilitarySymbologyCanvas to submit a draw command for the military symbol.
    MilitarySymbologyCanvas(canvas).drawMilitarySymbol().symbol(symbol).geometry(symbolGeometry).submit();
  }
};
public sealed class CustomMilitarySymbolPainter : IFeaturePainter
{
    public void ConfigureMetadata(FeaturePainterMetadata metadata)
    {
        // If the feature's geometry changes, the symbol needs to be painted on a different location.
        metadata.PainterDependsOnFeature(true);
    }

    public void Paint(Feature feature, FeaturePainterContext context, FeatureCanvas canvas)
    {
        // Create a geometry denoting the symbol's location.
        // For an icon symbol, this needs to be a point, so we use the center point of the feature geometry's bounds.
        var featureGeometry = feature.FindGeometry();
        if (featureGeometry == null)
        {
            Console.WriteLine("Ignoring feature '" + feature.Id + "'. It has no geometry.");
            return;
        }

        var center = featureGeometry.Bounds.Center;
        var symbolGeometry = GeometryFactory.CreatePoint(featureGeometry.Reference, center.X, center.Y, 0);

        // Create the military symbol to visualize. You can customize the symbol based on the feature.
        // In this example, we simply set the feature ID as value for the symbol text modifier "Unique Designation".
        var symbol = MilitarySymbol.Create(MilitarySymbology.Standard.MilStd2525d, "10030100001101000000");
        symbol.PutValue(MilitarySymbol.Modifier.UniqueDesignation, feature.Id.ToString());

        // Use a MilitarySymbologyCanvas to submit a draw command for the military symbol.
        new MilitarySymbologyCanvas(canvas).DrawMilitarySymbol().Symbol(symbol).Geometry(symbolGeometry).Submit();
    }
}
public static final class CustomMilitarySymbolPainter implements IFeaturePainter {
  @Override
  public void configureMetadata(FeaturePainterMetadata metadata) {
    // If the feature's geometry changes, the symbol needs to be painted on a different location.
    metadata.painterDependsOnFeature(true);
  }

  @Override
  public void paint(Feature feature, FeaturePainterContext context, FeatureCanvas canvas) {
    // Create a geometry denoting the symbol's location.
    // For an icon symbol, this needs to be a point, so we use the center point of the feature geometry's bounds.
    var featureGeometry = feature.findGeometry();
    if (featureGeometry == null) {
      System.out.println("Ignoring feature '" + feature.getId() + "'. It has no geometry.");
      return;
    }

    var center = featureGeometry.getBounds().getCenter();
    var symbolGeometry = GeometryFactory.createPoint(featureGeometry.getReference(), center.getX(), center.getY(), 0);

    // Create the military symbol to visualize. You can customize the symbol based on the feature.
    // In this example, we simply set the feature ID as value for the symbol text modifier "Unique Designation".
    var symbol = MilitarySymbol.create(MilitarySymbology.Standard.MilStd2525d, "10030100001101000000");
    symbol.putValue(MilitarySymbol.Modifier.UniqueDesignation, String.valueOf(feature.getId()));

    // Use a MilitarySymbologyCanvas to submit a draw command for the military symbol.
    new MilitarySymbologyCanvas(canvas).drawMilitarySymbol().symbol(symbol).geometry(symbolGeometry).submit();
  }
}