How to add a layer to JimuMapView in custom widget with corresponding Data Source

958
2
12-06-2021 02:54 PM
AlejandroMari1
Occasional Contributor

Hello! I'm trying to dynamically add layers to my map in a custom ExB Widget (1.5).

I've followed this to add layers: https://developers.arcgis.com/experience-builder/sample-code/widgets/add-layers/

That works in adding the layer to the map, but that's it. The layer doesn't have an associated JimuLayerView created in the JimuMapView, and also no associated data source.

I found I can call the method createJimuLayerViews() on the JimuMapView, and this creates the JimuLayerView, however, there is still no data source.

If I try to call getLayerDataSource() on the recently create JimuLayerView, it comes back undefined.

Any thoughts/ideas?

Thanks!

Alejandro

0 Kudos
2 Replies
JessicaRamirez1
New Contributor III

Hi Alejandro,

What other functionalities do you need besides adding the layer to the map? I've used the JimuLayerViews to identify all layers in my map and use those results to toggle the visibility of the layer I wanted. I have tried to use the same method as you did however, I don't get the results I'm looking for. If you're interested in how I did this I'll post it. 

0 Kudos
AlejandroMari1
Occasional Contributor

Thanks for your reply @JessicaRamirez1 . I need to add new layers to the map on the fly. And I need those layers to have proper data source (like all others in the web map) so I can manage selection.