Select to view content in your preferred language

How to retrieve complete layer list from a Map Service

216
1
Jump to solution
01-24-2025 06:33 AM
Labels (1)
LorenzoFerrari
Emerging Contributor

Hello everyone,
I am developing a custom widget, and I am trying to allow the user to load a single layer from a Map Service published on ArcGIS Server onto the map.
I would like to create a Select panel that displays the complete list of layers available in the Map Service so that the user can choose which layer to load. What is the best way to retrieve this list?
I'm using ExB Developer 1.15

Thanks!

0 Kudos
1 Solution

Accepted Solutions
JeffreyThompson2
MVP Frequent Contributor

You can load the MapImageLayer into memory, but not the map using this code.

// Typical usage
let layer = new MapImageLayer({
  // URL to the map service
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
});

Now the single layers will be available as an array on layer.sublayers.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublaye...

GIS Developer
City of Arlington, Texas

View solution in original post

1 Reply
JeffreyThompson2
MVP Frequent Contributor

You can load the MapImageLayer into memory, but not the map using this code.

// Typical usage
let layer = new MapImageLayer({
  // URL to the map service
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
});

Now the single layers will be available as an array on layer.sublayers.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublaye...

GIS Developer
City of Arlington, Texas