Using layer.sublayer to reference Feature layers in MapImageLayer

12-12-2018 03:09 PM
Regular Contributor

So I have a Mapservice that consists of a number of Feature Layers. So at REST endpoint each service has a URL ending in... :


If I want to run some geometry operations on these FeatureLayers, I was hoping to create a new layer:

   let myLayer = new MapImageLayer({
         url : https://.........../MapServer"

and then later, reference the underlying FeatureLayers as


But that results in 'undefined'. Is such only possible after I reference each sublayer when creating myLayer, such as...

   let myLayer = new MapImageLayer({
      sublayers : [
         {id : 0},
         {id : 1},
Or is there a simpler way to bring in all Feature layer and make them accessible? Can create list or collection of all feature layers and then reference them by index?
0 Kudos
2 Replies
MVP Esteemed Contributor


   Your issue is the method is called findSublayerById NOT findSubLayersById

Regular Contributor

Robert, thanks for chiming in and for all your other contributions throughout the community. Keep seeing your name all over the place. I think I may have snuck in the extra "s" when making my post because my original code the correct method. I guess where I was going with this question was whether I can only reference sublayers that are explicitly declared when I create my MapImageLayer, which means I'd have to list foo 13 sublayers along with creating naming names for them for later reference. I had hoped there would be a way to access the sublayers along with the names visible at the REST endpoint without having to hardcode them into my MapImageLayer definition.

0 Kudos