How to retrieve featurelayer object from map object?

1376
3
Jump to solution
09-12-2016 06:58 PM
baohuachu3
New Contributor III

Some FeatureLayers are added to map. How to retrieve one feature layer from map object? I have tried

map.getLayer(map.layerIds[x]), the object is not FeatureLayer type object.
0 Kudos
1 Solution

Accepted Solutions
PanagiotisPapadopoulos
Esri Regular Contributor

with the following

map.getLayer('MapServiceWeb_Operational_7147');

you are getting the map layer setting the layer id.

View solution in original post

3 Replies
PanagiotisPapadopoulos
Esri Regular Contributor

with the following

map.getLayer('MapServiceWeb_Operational_7147');

you are getting the map layer setting the layer id.

RobertScheitlin__GISP
MVP Emeritus

Baohoa,

   A FeatureLayer is always added to the map.graphicsLayerIds array and not the map.layerIds array. So the code would look like: 

map.getLayer(map.graphicsLayerIds[x]);

Or if you know the exact layer id the you can use the code Panagiotis provided.

baohuachu3
New Contributor III

Thank you so much for your guidance. 

0 Kudos