Using layer.sublayer to reference Feature layers in MapImageLayer

457
2
12-12-2018 03:09 PM
Arne_Gelfert
Occasional Contributor III

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

Mapserver/0
Mapserver/1
Mapserver/2
etc...

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

   myLayer.findSubLayersById(...)

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
RobertScheitlin__GISP
MVP Emeritus

Arne,

   Your issue is the method is called findSublayerById NOT findSubLayersById

Arne_Gelfert
Occasional Contributor III

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