Hello, I am working on an app that needs to use a specific feature layer for each user, based on some back-end logic. we have feature layer urls stored in our database that contain the feature layer needed for each user. currently we can access it using a series of api calls made with FeatureLayer objects. however, we can not expose the data to experience builder as a whole, as I can't seem to find a way to make a data source from the url.
is it possible for me to programmatically create a data source based on this feature layer url? is this even the right approach?
Hi, I was curious if you were able to figure this out yet?
I am looking to implement a similar approach for one of my apps.
Thanks
@aoestreicher @jrhodes-gst Yes, you can use the data source manager.
import { DataSourceManager, Immutable, DataSourceTypes, /** FeatureLayerDataSourceConstructorOptions, DataSourceJson */ } from 'jimu-core'
const featureLayerDs = await DataSourceManager.getInstance().createDataSource({
id: 'your_id',
dataSourceJson: Immutable({
id: 'your_id',
type: DataSourceTypes.FeatureLayer,
url: 'https://your_domain/arcgis/rest/services/service_name/FeatureServer/0',
layerId: '0',
itemId: 'the_id', // optional
portalUrl: 'https://org_name.arcgis.com', // optional
... // other properties in DataSourceJson
}),
layer: mapsSDKFeatureLayer, // optional, if you have one, https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html,
... // other properties in FeatureLayerDataSourceConstructorOptions
})