Select to view content in your preferred language

How can you access the layer behind a FeatureLayerDataSource

848
3
06-03-2022 03:22 PM
tbock
by
New Contributor

I am using the DataSourceComponent to query a feature layer and it is successfully querying it and rendering my content.  However I need access additional capabilities not directly supported in Experience Builder from what I can see.  The datasource I am getting from the DataSourceComponent appears to correctly be a FeatureLayerDataSource which has an optional property of layer.  It seems by default or by my configuration somehow layer is always undefined.   Count is also undefined by default but if you set queryCount on the component to true then count is loaded as the documentation indicates.  I don't see anything similar for the layer.  I've looked at the type definition for DataSourceComponent/DataSourceComponentProps which does show a few more properties than the documentation does but nothing seems to indicate that it would cause layer to be loaded. 

3 Replies
MarkJTurnbull
Regular Contributor

Hi tbock

Just wondering if you got a solution to this issue. I am encountering the same behavior, I think.

I have created a custom message action and as such can't use the DataSourceComponent, therefore I am using the raw DataSource objects as my datasources are all derived from the action's settings. I am trying to use a FeatureLayerDataSource based on a layer within a map service and finding that even once loaded the layer property is never populated and always remains undefined. Interestingly, the restLayer property is populated, but it does not meet all my needs. If I wrap the map service in a web map and reference the layer via that web map the child FeatureLayerDataSource does populate the layer property and my action works, however I don't want to have to create web map wrappers to overcome this issue and would prefer to be able to reference the layer from the map service itself.

I also tried pushing a new Javascript API FeatureLayer object based on the FeatureLayerDataSource's url property into its layer property, but this just caused my whole app to have conniptions.

I am using Experience Builder Dev. Ed. v1.12

Is anyone from the Experience Builder product team able to explain this behavior or provide some information about what part of the DataSource lifecycle the layer is/should be populated? 

tbock
by
New Contributor
* I'm going off memory as it has been a while. But I believe the solution was the dependency attribute of the widget manifest.json<> file for the widget. If I am remembering correctly, adding that attribute with the value "jimu-arcgis" essentially causes the widget to wait to load until the ArcGIS JS SDK is loaded. At the time I didn't feel like this was documented clearly (at all?) but the example js-api-widget they provide has this dependency set<> so it made sense. If someone has a link to documentation that more clearly explains this behavior that would be helpful. I still find the documentation a bit confusing since it says "jimu-arcgis: will load the jimu-arcgis package that will load the ArcGIS Maps SDK for JavaScript.". However, the JS SDK often loads even if you don't do this. I suspect its more accurate to say that the builder will make sure the JS SDK is loaded before your widget or something along those lines.
0 Kudos
RichardKorsós
New Contributor

Hi,

 

I have the same issue. Could you find the solution?

 

Maybe It can be the solution:

const layer = ds.layer || await ds.createJSAPILayerByDataSource();

 

Thanks

0 Kudos