Select to view content in your preferred language

Custom Widget Adds Layer But are not selectable on map

101
2
Jump to solution
2 weeks ago
Labels (1)
jsu
by
New Contributor

Hi all, 

I'm very new to experience builder. I've created a custom widget that when the user presses a button, adds a layer hosted on my ArcGIS Online. However, after adding the layer, despite being able to see it displayed on the map, I am unable to select / edit it using the select / editor tools. Is there some specific property I need to enable when I add the layer to enable selection / editing? 

 

I can't add the layer in as a datasource on the map beforehand, since I plan on adding functionality to create and add custom layers based on user input. 

0 Kudos
1 Solution

Accepted Solutions
jsu
by
New Contributor

Hi Jeffrey, thank you so much! This repo has a lot of valuable examples. I realized that the issue was that while I was creating a data source, I was adding the layers to my map via: jmv.view.add(layer). When I added the layer via jmv.addLayerAndCreateJimuLayerView(layer, datasource), I was able to select and edit.

Thank you for providing your add/remove layer tool - I was only able to notice this after looking through your code. 

View solution in original post

0 Kudos
2 Replies
JeffreyThompson2
MVP Frequent Contributor

In order to get a layer to work with many of the built-in Widgets including Select and Edit, the layer must be converted to a Experience Builder Datasource. Here is the official example: https://github.com/Esri/arcgis-experience-builder-sdk-resources/tree/master/widgets/data-source-widg...

Here is a completed widget designed for adding layers as Datasources: https://community.esri.com/t5/experience-builder-custom-widgets/add-remove-layers-3-0-full-settings-...

GIS Developer
City of Arlington, Texas
0 Kudos
jsu
by
New Contributor

Hi Jeffrey, thank you so much! This repo has a lot of valuable examples. I realized that the issue was that while I was creating a data source, I was adding the layers to my map via: jmv.view.add(layer). When I added the layer via jmv.addLayerAndCreateJimuLayerView(layer, datasource), I was able to select and edit.

Thank you for providing your add/remove layer tool - I was only able to notice this after looking through your code. 

0 Kudos