Hi,
@YueyangLi @QunSun @JeffreyThompson2 @Wei_Ying
I'm preparing a client-side feature layer and I want to add it to the map. I also want to enable DataActions so I can perform actions like Add To Table, Set Filter, Pan To, Export, etc. I've tried several approaches, including the following samples:
const polygonGraphic = new Graphic({
geometry: {
type: 'polygon',
rings: [
[
[350000, 6250000],
[350500, 6250000],
[350500, 6250500],
[350000, 6250500],
[350000, 6250000]
]
],
spatialReference: { wkid: 3308 }
},
attributes: {
OBJECTID: 1,
Name: 'DemoArea',
Type: 'Test'
}
})
const demoLayer = new FeatureLayer({
source: [polygonGraphic],
objectIdField: 'OBJECTID',
geometryType: 'polygon',
spatialReference: { wkid: 3308 },
fields: [
{ name: 'OBJECTID', alias: 'OBJECTID', type: 'oid' },
{ name: 'Name', alias: 'Name', type: 'string' },
{ name: 'Type', alias: 'Type', type: 'string' }
],
title: 'Demo_3308_Layer'
})
const demoLayerLayerView = await jimuMapView.createJimuLayerView(demoLayer, `runtime_layer_${dsId}`, 0, null, true)
The layer view is created successfully, but when I try to create the DataSource using the layer view:
const ds = await demoLayerLayerView.createLayerDataSource()
…it returns null.
I also tried creating a dataSourceJson object manually:
const dataSourceJson: IMDataSourceJson = Immutable({
id: demoLayer.id,
label: demoLayer.title,
sourceLabel: 'Client-Side Layer',
type: 'FEATURE_LAYER',
geometryType: demoLayer.geometryType,
isDataInDataSourceInstance: true, // means data will live in memory
isOutputFromWidget: true,
isHidden: false,
disableExport: false,
schema: schema,
data: [demoLayer.source.items[0].attributes], // optional initial empty dataset
useFields: Object.keys(fieldsSchemaObj),
});
const dsOptions: DataSourceConstructorOptions = {
id: dsId,
dataSourceJson: dataSourceJson
}
const ds1: FeatureLayerDataSource = await DataSourceManager.getInstance().createDataSource(dsOptions)
const message = new DataSourcesChangeMessage(props.widgetId, DataSourcesChangeType.Create, [ds1])
MessageManager.getInstance().publishMessage(message)
This creates a DataSource, but DataActions are not enabled. Any help or guidance on enabling DataActions for a client-side feature layer would be appreciated.