I’m currently using ArcGIS JavaScript API 4.5 but hope to move to 4.9 soon. Either way, the issue is the same even on my test 4.9 app.
I want graphics, such as draw, to show in the printed map but not in the legend. The JS 3.x API would do this but 4.x makes a legend item which says “polygonLayer” and the graphic called “Override 1”. This makes the printed map look silly. (see attached image)
I followed advice found here and intercepted the Print request and removed my graphics layers from the operationalLayers in the Web_Map_as_JSON. However, this also removes the graphics from the map.
So in 4.x, is there a way to keep graphics in the map but remove them from the legend?
Thanks!
Daniel,
In 4.x you have the legendEnabled property for the layer:
Does GraphicsLayer have the ' legendEnabled' property? I tried setting it to false anyway but it doesn't work. The graphics still appear in the legend.
Daniel,
A GraphicsLayer does not have that property. So you should switch from using a GraphicsLayer and use a FeatureLayer instead. A FeatureLayer has a source property that is an collection of graphics.
Create a FeatureLayer with client side graphics | ArcGIS API for JavaScript 4.9
I did the FeatureLayer thing instead, set legendEnabled to false, but they still show in the legend. Only now they have a long id as the title.
Daniel,
When you say legend you mean the print output legend? If so I am sorry we have been miscommunicating. The legendEnabled is for the legend widget in the map.
Yes, this is for the printed legend in the printed map. Is there a way to remove graphics from printed legend but to keep them in printed map?
I was thinking that they fixed the override label in the print legend in ArcGIS Server 10.6.1...