Select to view content in your preferred language

capture all map and layers that are existing in the application when a button is clicked

1370
3
Jump to solution
08-04-2016 06:25 PM
Alexwang
Frequent Contributor

Hello, new to the arcgis dev. My question is how  to get all base maps and operational layers with a button click on a widget? the button click should capture all map and layers that are currently existing in the application when button click is triggered. Please share the codes. Thanks,

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

  You can use the LayerInfos class in WAB:

LayerInfos class—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers

There is a code snippet in the above doc page.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

  You can use the LayerInfos class in WAB:

LayerInfos class—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers

There is a code snippet in the above doc page.

Alexwang
Frequent Contributor

Always thank you for your replies, Robert.

just confirm: is LayerInfos.getInstance(this.map, this.map.itemInfo) able to catch all layers (base map tiles, graphics, feature layer, and any dynamic layers added by users)?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

Yes. Use getBasemapLayers function to get basemaps and getLayerInfoArray for all operational Layers