AnsweredAssumed Answered

ArcGIS JS 4.x get all featurelayers in the map

Question asked by jcarasick on May 21, 2018
Latest reply on May 22, 2018 by jcarasick

I am trying to get a list of all featurelayers in the map. Currently i am looping through each layer/sublayers in the map and calling createFeatureLayer() on the sublayer.

 

Sometimes this returns a featurelayer as expected. other times it returns null or undefined for a group layer for example (which is fine).

 

The issue i am seeing is when i do get a featurelayer back i am getting them back for RasterLayers that are in the map. if i check the featurelayer.type i do get "feature". I wasn't expecting this. Maybe this is a bug?

 

Is there a way i can find all queryable layers (featurelayer) without having to further call the featurelayer.load() method to further interrogate the fields array to see if it's queryable?

 

The end goal is for every layer in the map (feature or table) i am trying to provide a function to open a table or set a definition query for example.

Outcomes