LabelDefinitions ToJson returns a null symbol - ArcGIS Runtime .Net v100.2

390
0
02-02-2018 12:41 PM
NicoleRoe1
New Contributor

We have one GraphicsOverlay where we want to display the labels from many FeatureLayers.  We want to load the LabelDefinitions from the FeatureLayers into the single GraphicsOverlay while applying an additional where clause to each LabelDefinition.

The issue is that the symbol that is deserialized in the LayerDefinition.ToJson() method is blank.

We can work around this by manually creating a symbol but it is not ideal as we loose the FeatureLayer label symbology that the users expect.

I downloaded your WPF template app and have written code in the MapViewModel to reproduce this issue.  The attached project contains the code and data to reproduce.

As written the labels will be loaded on the single graphics overlay.  The labels will not render as they have no symbol.

Comment line 66 and re-run to see the labels rendered properly from the feature layer.

        private void AddLabelsToGraphicsLayer()
        {
            foreach (FeatureLayer layer in _map.OperationalLayers.Where(l => l is FeatureLayer))
            {
                layer.LabelsEnabled = false;

                foreach (LabelDefinition labelClass in layer.LabelDefinitions)
                {
                    // THE ISSUE IS THIS TOJSON RETURNS AN EMPTY SYMBOL
                    _graphicOverlay.LabelDefinitions.Add(LabelDefinition.FromJson(labelClass.ToJson()));
                }
            }

            _graphicOverlay.LabelsEnabled = true;
        }

How do we get the same labels on the FeatureLayer and GraphicsOverlay?

Is there a way to do this and alter the where clause without having to deserialize?

Is the empty deserialized symbol a bug?

0 Kudos
0 Replies