AnsweredAssumed Answered

How to create a FeatureLayer based on a FeatureCollectionTable

Question asked by m.glasesri-de-esridist Employee on May 6, 2019
Latest reply on May 7, 2019 by NFurness-esristaff

Hi,

 

the Runtime documentation describes five constructor, which could be used to create a FeatureTable. One of them creates a class based on a FeatureTable.

Normally, a FeatureTable is based on a service, such as the ServiceFeatureTable, and is usually stored in a database. But I need a FeatureLayer on the fly based on in memory data. 

So I thought in my case the FeatureCollectionTable would be the right way, because it is based on a FeatureTable and so I should be able to create a FeatureLayer from it.

 

The following code is compileable:

var fields = new List<Field> {new Field(FieldType.Text, "Field1", "Field1", 50)};
var table = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.WebMercator);
var featureLayer = new FeatureLayer(table);
MyMapView.Map.OperationalLayers.Add(featureLayer);

But when executing this code, I got an exception:

System.ArgumentException: 'Invalid argument: Cannot create a feature layer from a feature collection table. Add the feature collection table to a feature collection.'

 

Now I'm a bit confused: Why can't I do that, a FeatureCollectionTable inherits from the FeatureTable?
Is that a bug? Is this work as designed?

A FeatureCollection doesn't get me where I want to be: Among other things, I want to be able to restrict data by DefinitionExpression, but this is only possible with the FeatureLayer.

 

Kind regards,

Max

Outcomes