Hi,
I am trying to print secured services and it works fine for most of the part except that the labeling info does not show on the print output.
While I am preparing the map, the labels do appear, but do not show up on print output.
I am using ESRI JS API v3.25.
var labelJson = {
"labelExpressionInfo": { "expression": "" },
"useCodedValues": false,
"labelPlacement": ""
};
labelJson.labelExpressionInfo.expression = "CONCATENATE([$feature.NAME, $feature.CLASS], ' / ')";
labelJson.labelPlacement = "above-right";
var labelSymbol = new textSymbol();
var lblClass = new labelClass(labelJson);
lblClass.symbol = labelSymbol;
printFeatLyrEquipment.setLabelingInfo([lblClass]); //this is a Feature layer
map.addLayer(printFeatLyrEquipment);
Not sure why is it not printing the labels...any clues?
Thanks in advance!
~UJ
Solved! Go to Solution.
Okay...so feature layers don't seem to support labels while printing.
I turned on the relevant layers from the dynamic service using setVisibleLayers() and apply definition query/label expression using setDefinitionExpression() & setDynamicLayerInfos() respectively - and the labels appear beautifully in the print output!!!
Regards
UJ
Okay...so feature layers don't seem to support labels while printing.
I turned on the relevant layers from the dynamic service using setVisibleLayers() and apply definition query/label expression using setDefinitionExpression() & setDynamicLayerInfos() respectively - and the labels appear beautifully in the print output!!!
Regards
UJ
Is it possible to post your solution here? We have the same problem. We are using FeatureLayer and labels are missing when exported as pdf/image. Thanks
Just to chime in here, there are a couple of caveats about printing labels with FeatureLayers:
PrintTask | API Reference | ArcGIS API for JavaScript 4.9
labelsVisible
property must be explicitly set to true
for labels to be printed.FeatureLayer | API Reference | ArcGIS API for JavaScript 4.9
-Noah
So if I understand well with 4.9 API it is not possible to print FeatureLayer labels but with older 3.xx this is possible?
I have same problem and I'm using 4.9 js API.
This should work fine at 4.9. I am pretty sure that printing labels has been supported since labeling was introduced to 2D MapViews at version 4.8. What sort of issue are you seeing?
We now use view.takeScreenshot() but labels added to view as labelClass didn't show on result image of PrintTask
cluLayer = new w.FeatureLayer({url: url,
labelingInfo: [labelClass],
renderer: renderer
})
map.add(cluLayer);
I think in this case the labelsVisible
property must be explicitly set to true
for labels to be printed.