Select to view content in your preferred language

Adding a FeatureLayer that can be used in select/table

242
3
Jump to solution
09-16-2024 08:59 AM
jwilner_amica
Occasional Contributor

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:
jwilner_amica_0-1726502255530.png

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

jwilner_amica_1-1726502288238.png

 

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

jwilner_amica_2-1726502357615.png

 

Thank you!

0 Kudos
2 Solutions

Accepted Solutions
JeffreyThompson2
MVP Regular Contributor

There are two ways to add a FeatureLayer to Experience Builder. If you use the methods from the JavaScript API, the data will only be visually accessible. To get all of the data functionality, it must be transformed, added and recognized as an Experience Builder datasource.

This thread should help. https://community.esri.com/t5/arcgis-experience-builder-questions/making-runtime-featurelayers-regis...

GIS Developer
City of Arlington, Texas

View solution in original post

0 Kudos
jwilner_amica
Occasional Contributor
0 Kudos
3 Replies
JeffreyThompson2
MVP Regular Contributor

There are two ways to add a FeatureLayer to Experience Builder. If you use the methods from the JavaScript API, the data will only be visually accessible. To get all of the data functionality, it must be transformed, added and recognized as an Experience Builder datasource.

This thread should help. https://community.esri.com/t5/arcgis-experience-builder-questions/making-runtime-featurelayers-regis...

GIS Developer
City of Arlington, Texas
0 Kudos
jwilner_amica
Occasional Contributor

Thank you for the quick response, I'll give that a look!

0 Kudos
jwilner_amica
Occasional Contributor

Reference this solution, in my case the other worked, but had issues with renderer.

https://community.esri.com/t5/arcgis-experience-builder-questions/loss-of-renderer-with-runtime-crea...

0 Kudos