Select to view content in your preferred language

Loss of runtime-created datasource functionality on layer re-order

409
8
Jump to solution
4 weeks ago
jwilner_amica
Occasional Contributor

I've managed to successfully create and add a data source to map, preserving its rendering and giving it DataSource capabilities (add to table, select tool, etc.). However, those DataSource capabilities are lost as soon as the layer is reordered in the layer list widget. My FeatureLayer and DataSource are defined as follows:

                                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,
                                    layerId: 0,
                                })
                                const data: DataSourceJson = {
                                    id: 'hail_ds_' + dt,
                                    layerId: layer.id,
                                    type: DataSourceTypes.FeatureLayer,
                                    label: layer.title,
                                }

                                const dataJson = Immutable(data)
                                const dataSourceOptions = {
                                    id: 'hail_ds_' + dt,
                                    layer: layer,
                                    layerId: layer.id,
                                    dataSourceJson: dataJson,
                                }

                                dsManager.current.createDataSource(dataSourceOptions).then((source) => {
                                    map.current.view.map.add(layer)
                                    console.log(layer.id)
                                    map.current.createJimuLayerView(
                                        layer, map.current.id, layer.id, source, true
                                    ).then((response) => {
                                        console.log(response)
                                        setStatus('Hail from ' + dt + ' added')
                                    })
                                }).catch((error) => {
                                    console.error('Error creating DataSource:', error);
                                });

 

Unsure why reordering removes DataSource functionality, I assume it is something to do with the layerId property, but I cannot find a sensible configuration of that property that makes it work, so it may not be that at all.

This post is a follow-up on runtime FeatureLayer / DataSource creation, for more prior context as to how I got here, reference this post:

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

 

0 Kudos
2 Solutions

Accepted Solutions
JeffreyThompson2
MVP Regular Contributor

I did a little testing. This appears to be a bug in Experience Builder 1.15. Using an application built in Developer Edition 1.14, runtime added layers re-order without issue, but using the version in ArcGIS Online, I see the behavior you describe.

GIS Developer
City of Arlington, Texas

View solution in original post

TonghuiMing
Esri Regular Contributor

Yes, we will take a look at this issue. Thanks for bringing it up @jwilner_amica @JeffreyThompson2 

View solution in original post

0 Kudos
8 Replies
jwilner_amica
Occasional Contributor

This functionality issue is also present in layers added to the map by Esri's 'Add Data' widget, but it is NOT present in layers that exist within a Web Map already. As such, it seems to be something unique to adding during runtime.

0 Kudos
JeffreyThompson2
MVP Regular Contributor

I did a little testing. This appears to be a bug in Experience Builder 1.15. Using an application built in Developer Edition 1.14, runtime added layers re-order without issue, but using the version in ArcGIS Online, I see the behavior you describe.

GIS Developer
City of Arlington, Texas
jwilner_amica
Occasional Contributor

Interesting! Hopefully ESRI sees this and can get around to patching it. Thank you for finding that, I've only done work in 1.15.

0 Kudos
JeffreyThompson2
MVP Regular Contributor

This is actually a pretty big bug. I'm going to tag a couple developers, so they can look into it further.

@TonghuiMing @WeiYing1 @YueyangLi 

GIS Developer
City of Arlington, Texas
TonghuiMing
Esri Regular Contributor

Yes, we will take a look at this issue. Thanks for bringing it up @jwilner_amica @JeffreyThompson2 

0 Kudos
BrianLeroux
Frequent Contributor

I did open a support case for this in order to log a bug. Case #03730665. I have not heard back if a bug was actually created yet.

0 Kudos
FangQi
by
New Contributor

It looks like this is caused by a corner case when you try to reorder layers in a map-layers widget that connects to a map widget without a web map. We will dig into it, thanks.

0 Kudos
BrianLeroux
Frequent Contributor

Bug has been created for this issue. Bug number: BUG-000171121 

0 Kudos