I am trying to add a FeatureLayer to my map. It adds visually, and to Layer list, but cannot be added to the attribute table, or used in select widget, etc. I assume it is an issue where it needs to be added as a data source, but I haven't been able to figure that out. Any help would be appreciated!
const data: DataSourceJson = {
id: 'Hail Swath ' + dt,
layerId: layer.id,
type: DataSourceTypes.FeatureLayer,
geometryType: layer["geometryType"],
label: layer.title
}
const dataJson = Immutable(data)
const dataSourceOptions = {
id: 'Hail Swath ' + dt,
layer: layer,
dataSourceJson: dataJson
}
const something = dsManager.current.createDataSource(dataSourceOptions).then((dataSource: FeatureLayerDataSource) => {
map.current.view.dataSourceId = dataSource.id
map.current.view.map.add(dataSource.layer);
}).catch((error) => {
console.error('Error creating DataSource:', error);
});
The layer is defined as such:
let layer = new FeatureLayer({
source: featureset, // autocast as a Collection of new Graphic()
objectIdField: "OBJECTID",
geometryType: "polygon",
popupTemplate: template,
fields: swath.value.fields,
title: 'Hail Swath ' + dt,
opacity: 0.8
})
and uses a unique-value renderer
It adds to layer list:

but with limited functionality compared to other layers added through Add Data widget:

It also does not show up in the Add Data widget:

Thank you!