ArcGIS Runtime SDK for .NET Printing Military Message Layers

2602
0
10-29-2015 07:15 PM
PeterDavis3
New Contributor II

We have setup printing feature based on the Client Print Sample provided on GitHub. Everything is working except for the Military Message Layers not being displayed.

I am trying to get the most basic sample together with the print sample to display a 2525C symbol on the print preview, but I cannot get anything to work. If I try and programmatically add a message layer to the the print sample it throws an InvalidOperationException

"The Message could not be processed. MessageLayer must have been successfully loaded into a View (Map or Scene) before calling ProcessMessage."

Hack to ClientPrinting.xaml.cs sample:

if (PrintMapView.Extent == null)
{
    PrintMapView.MaximumExtent = BaseMapView.MaximumExtent;
    PrintMapView.MaxScale = BaseMapView.MaxScale;
    PrintMapView.MinScale = BaseMapView.MinScale;
    PrintMapView.SetRotation(BaseMapView.Rotation);
    PrintMapView.WrapAround = BaseMapView.WrapAround;
    PrintMapView.Map = BaseMapView.Map;

    await PrintMapView.LayersLoadedAsync();
    // create a dictionary to hold message properties
    var messageProps = new Dictionary<string, string>();

    // define message properties (property name, value)
    messageProps.Add("_type", "position_report");
    messageProps.Add("_action", "update");
    messageProps.Add("_id", "e0ba16ac-cddd-4595-845e-32ca4177d080");
    messageProps.Add("_control_points", "-117.187,32.770;-117.191,32.725;-117.097,32.653;-116.944,32.610");
    messageProps.Add("_wkid", "4326");
    messageProps.Add("sic", "GFGPOAO-------X");
    messageProps.Add("uniquedesignation", "IGLOO");

    // create the message using the properties
    var message = new Esri.ArcGISRuntime.Symbology.Specialized.Message(messageProps);

    // get the message layer from the map
    var messageLayer = new MessageLayer(SymbolDictionaryType.Mil2525c)
    {
        ID = "MyMessageLayer"
    };

    PrintMapView.Map.Layers.Add(messageLayer);
    // make sure it's loaded before using it
    await PrintMapView.LayersLoadedAsync(new[] {messageLayer});
    // call ProcessMessage on the layer
    bool success = messageLayer.ProcessMessage(message);
    if (!success)
    {
        Trace.WriteLine("Failed to process message.");
    }
}

Has anyone managed to print a map with military symbols on it?

Note that I am testing this against version 10.2.6

0 Replies