AnsweredAssumed Answered

results layer not displaying labels

Question asked by franklin.alexander on Apr 29, 2019
Latest reply on Apr 29, 2019 by franklin.alexander

I have a web app built with WAB 2.10 that display two layers, I polygon and a point layer which are hosted at ArcGIS REST services. Both of the layers have labels that were configured in the ArcGIS map document and then published. Originally I brought in the layers as feature classes and the labels would not render. I then brought them in as a dynamic layer and now I can get the labels to show. I don't really understand why they don't show when I add the layers to the map as feature layers, since this would be my preference, but I can work around this. 

 

The problem is that I am running a query on the point layer (since I don't need to see all of the points), but I cannot get the labels to show for the resulting point layer. The is perplexing, because the drawing info for the result layer is cloned from the original REST layer (which shows labels). 

 

var layerInfo = lang.clone(currentAttrs.layerInfo);

var featureCollection = {
          layerDefinition: layerInfo,
          featureSet: null
        };
        //For now, we should not add the FeatureLayer into map.
        //resultLayer = new FeatureLayer(featureCollection);

        resultLayer = new FeatureLayer(featureCollection, {
            outFields:["*"],
            showLabels: true
});

 

and when I log out the result layers info, all of the labeling info appears to be present in the layer properties. 

 

Here is the query result layer not showing any labels:

 

There must be something else I need to be doing to get the labels to show, but I can't figure it out. The only thing I can think of is that either something is missing in the label properties, or it has something to do with the rendering. Do I need to add something to the code snippet below?

 

if(!queryUtils.isTable(currentAttrs.layerInfo)){
          if(!currentAttrs.config.useLayerSymbol && currentAttrs.config.resultsSymbol){
            var symbol = symbolJsonUtils.fromJson(currentAttrs.config.resultsSymbol);
            renderer = new SimpleRenderer(symbol);
            resultLayer.setRenderer(renderer);
          }
}

 

One other thing I have tried, is to use the LabelClass constructor as described in esri's javascript API reference page here: https://developers.arcgis.com/javascript/3/jsapi/labelclass-amd.html, but no luck.

 

I don't know where to go from here, so if anyone sees anything obvious I am missing please let me know. 

 

Thanks! 

Outcomes