map.getLayer(id) always retuns null

7956
11
06-23-2011 06:40 PM
JesseMetcalfe
New Contributor
Hi,
I want to access a layer from my mapservice so that I can query and apply definition expression to it.
But I am always getting null valye when I access map.getLayer("id") method.

Any help on the right direction is greatly appreciated.

Jesse
Tags (2)
0 Kudos
11 Replies
EzequiasRodrigues_da_Rocha
New Contributor III
Lucas,

   You can not retrieve a sublayer from the map using this or any function, only a whole Map Service.


Is this real? can't we retrieve the state of any FeatureLayer? Where do we can find this limitation on the documentation Robert?


Ezequias
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ezequias,

   The name "layer" is used by the API in a way that can be confusing. Think of a layer as more of a map service in MOST cases. When working with an ArcGISDynamicMapServiceLayer you are not able to get reference to an individual sublayer of the map service by using map.getLayer function. Using ArcGISDynamicMapServiceLayer you can get access to the sublayers visibility and you can set the layer definition but not a lot more. You can not really call this a limitation that is stated in the documentation, it is more of understanding what abilities the ArcGISDynamicMapServiceLayer actually has by reading the docs.
0 Kudos