AnsweredAssumed Answered

FeatureCollectionTable Unique Value Renderer

Question asked by ag.timmons on Mar 21, 2019
Latest reply on May 14, 2019 by ag.timmons

Hello,

 

In my mobile app, I am creating a new featureCollectionLayer by copying the selected features from a feature layer to a FeatureCollectionTable as follows-

 

 private async Task CreateNewFeatureCollection(FeatureQueryResult features, Renderer renderer)
        {
            // Create the schema for the table

            var fields = features.First().FeatureTable.Fields;

            // Instantiate FeatureCollectionTables with schema and geometry type
            FeatureCollectionTable featureCollectionTable = new FeatureCollectionTable(fields, features.GeometryType, SpatialReferences.WebMercator);

            // Set rendering for each table
            featureCollectionTable.Renderer = renderer;

            foreach (Feature feature in features)
            {
                //Debug.WriteLine(feature.GetAttributeValue("SURTYPE").ToString());
                Feature newFeature = featureCollectionTable.CreateFeature(feature.Attributes, feature.Geometry);
                await featureCollectionTable.AddFeatureAsync(newFeature);
            }


            FeatureCollection featuresCollection = new FeatureCollection();
            featuresCollection.Tables.Add(featureCollectionTable);

            // Create a FeatureCollectionLayer 
            FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection);

            // When the layer loads, zoom the map centered on the feature collection
            await collectionLayer.LoadAsync();

            // Add the layer to the Map's Operational Layers collection
            if(features.GeometryType == GeometryType.Point)
                Map.OperationalLayers.Add(collectionLayer);
            else
            {
                if (Map.OperationalLayers.Count > 1)
                    Map.OperationalLayers.Insert(1, collectionLayer);
                else
                    Map.OperationalLayers.Add(collectionLayer);
            }



        }

I use a unique value renderer for featureCollectionTable as follows-

 

     public Renderer GetTrailsQueryRenderer()
        {

            UniqueValueRenderer renderer = new UniqueValueRenderer();

            renderer.FieldNames.Add("SURTYPE");

            SimpleLineSymbol hardLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.FromArgb(255, 51, 204), 2);
            SimpleLineSymbol softLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.FromArgb(255, 51, 204), 2);

            // Add values to the renderer: define the label, description, symbol, and attribute value for each
            renderer.UniqueValues.Add(
                new UniqueValue(" ", "Hard Surface", hardLineSymbol, "HardSurface"));
            renderer.UniqueValues.Add(
                new UniqueValue(" ", "Soft Surface", softLineSymbol, "SoftSurface"));


            // Set the default region fill symbol (transparent with no outline) for regions not explicitly defined in the renderer
            renderer.DefaultSymbol = hardLineSymbol;
            return renderer;
        }

 

However the renderer doesn't work for unique values and only shows the hardLineSymbol because it has been set as the default symbol as well. I have checked the attributes of features and they look good its the renderer it seems that is not changing shapes for unique values.

 

Thanks

 

Apurva

Outcomes