layerNode.getLayerType() not working for layers inside group layers

497
0
07-10-2019 07:07 AM
by Anonymous User
Not applicable

I'm trying to determine layer types for the current map service.

The starter code here is great: https://developers.arcgis.com/web-appbuilder/api-reference/layerstructure.htm

I'm doing the following, which mostly works.

printLayerTree:function() {
    // dont need to lang.hitch, but here because was calling into outside functions
    this.layerStructure.traversal(lang.hitch(this,function(layerNode) {
        var indent = "";
        for(var i = 0; i < layerNode.getNodeLevel(); i++) {indent += "  ";} 
            layerNode.getLayerType().resolve().then(function(lt){
                console.log(indent, layerNode.title + " >> " + lt);
            });

    }));
},‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

However, for layers in group layers inside a map service, its failing to get type. From the below the first 2 are feature service layers, the 3rd is a map service (Gillnet is a single layer added to webmap directly), and the Coral and Commercial Fishery are entire map services that make use of Group Layers (the GL type shows up, but not the "Feature Layer/ Raster Layer").

DataViewerEditExample - Resource Points >> FeatureLayer
DataViewerEditExample - Shoreline >> FeatureLayer
Gillnet 2012-2015 >> FeatureLayer
Coral Conservation Protection >> ArcGISDynamicMapServiceLayer
   Marine Protected Areas >> undefined
   Provincial_Ecological_Reserves >> undefined
   Other Effective Area-Based Conservation Measure >> undefined
Commercial Fishery by Gear Type >> ArcGISDynamicMapServiceLayer
   Fixed Gear >> GroupLayer
     Gillnet >> GroupLayer
       Gillnet 2012-2015 >> undefined
       Gillnet 2008-2011 >> undefined
     Longline >> GroupLayer
       Longline 2012-2015 >> undefined
       Longline 2008-2011 >> undefined
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Further research:

- fails in the same way for both 10.4.1 and 10.6.1 (so it's not the server)

The layerNode._layerInfo.layerObject has a key/value of   empty:true for layers that are returning undefined types. So I tried to getLayerObject(), but the results for these layers all return undefined as well. This seems related. Perhaps something isn't hydrated. But not sure how I can force it short of calling the functions I already am...

	var def = new Deferred();
	layerNode.getLayerObject().then( function(layerObject) {
	  def.resolve(layerObject);
	});

Am I doing something wrong?

thanks

0 Kudos
0 Replies