I refered the first link as suggested by you and it worked in Developer edition 1.16. The same logic I tried in 1.14 it did not work and not throwing any error message. The reason I am using 1.14 is my Portal version is 11.3.
const layer = new FeatureLayer({
source: [ptGraphic],
fields: [{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
}, {
name: "place",
alias: "Place",
type: "string"
},{
name: "Description",
alias: "Description",
type: "string"
}],
objectIdField: "ObjectID",
geometryType: "point"
});
layer.title = "Sample Layer";
layer.id = "sampleLayer";
const dataSourceManager = DataSourceManager.getInstance();
const dataSourceId = "dataSource_1";
//const layerInfo = jmv.view.map.allLayers.items[39]
//const dataSourceId = "dataSource_1";
const data: DataSourceJson = {
id: 'sample layer',
layerId: layer.id,
type: DataSourceTypes.FeatureLayer,
label: layer.title,
}
const dataJson = Immutable(data)
const dataSourceOptions = {
id: 'Sample client side layer',
layer: layer,
dataSourceJson: dataJson,
}
//const jimuLayerView = await jimuMapView.addLayerAndCreateJimuLayerView(layer, dataSource);
dataSourceManager.createDataSource(dataSourceOptions).then((source) => {
const sourceId = source.id
const addMapData = {
jimuMapViewId: jmv.id,
dataSourceId: sourceId,
dataChangeType: DataChangeType.Create,
dataChangeStatus: DataChangeStatus.Fulfilled
}
jmv.view.map.add(layer)
jmv.createJimuLayerView(layer, jmv.id, 0, source, true)
//let mapDatas = { sourceId: addMapData }
//jmv.view.map.addOrRemoveDataOnMap(mapDatas)
}).catch((error) => {
console.error('Error creating DataSource:', error);
});