Select to view content in your preferred language

How do I get the layer ID of a layer on a map widget

200
2
07-16-2024 12:54 PM
ShahranNewaz
Emerging Contributor

Hi, so I'm working on creating a custom widget that will export the data of a layer into a CSV file. But I'm stuck on the part where I have to retrieve the layer ID of the layer I want to export. This is how I'm trying to do it.

 

 

const featureLayer = jimuMapView.view.map.findLayerById('layerid') as esri.FeatureLayer;

 

 

 layerid is where the retrieved ID would go. Thx in advance.

0 Kudos
2 Replies
QunSun
by Esri Contributor
Esri Contributor

Hi ShahranNewaz,

Is your problem that you don't know the id of the layer to be exported? If you don’t know the layer id, how do you know which layer to export?

0 Kudos
JeffreyThompson2
MVP Regular Contributor

https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#allLayers

The simplest way to find the id of a layer if you don't know it is to console log all layers and look through the results with your browser tools.

console.log(jimuMapView.view.map.allLayers)
GIS Developer
City of Arlington, Texas
0 Kudos