Printing with Legend

2472
7
Jump to solution
11-30-2012 04:02 AM
MarkHoover
Occasional Contributor II
Can someone post a sample or at least a chunk of code on how to use 10.1's Web Printing capabilities with a legend?  The Print Service works for me, even when publishing my own, but the legend seems to be ignored.  I have a legend in my map document and have tried the following bit of code, per the API reference, with no luck:

 var legendLayer = new esri.tasks.LegendLayer();         legendLayer.layerId = '_cADMLocations';         legendLayer.subLayerIds = [0];         template.layoutOptions = {             titleText: 'My First Map',             authorText: 'Mark Hoover',             scalebarUnit: 'Miles',             legendLayers: [legendLayer]         };
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor
so your adapted app works with the SampleServer6 layout templates with legends, but when pointing at your own custom template, not even the title displays, correct?

i don't recall doing anything special when i created and published my own custom templates, but i think i started by modifying the ones that come preinstalled.  here's a screenshot of the property page for mine for you to compare and contrast.

the cool thing is you can make changes to the MXD on the fly and see them in print output without touching your service.

[ATTACH=CONFIG]19636[/ATTACH]

View solution in original post

0 Kudos
7 Replies
JohnGravois
Frequent Contributor
check out the jsfiddle link i posted in this thread
you should be able to copy the code onto your own web server and view legend swatches (after updating the proxy reference)
0 Kudos
MarkHoover
Occasional Contributor II
No luck.  Actually, the legend I have on my Map Document isn't showing up at all (it should show its title "Legend" no matter what, right?)  When you add the legend to the Map Document that is the Template base, all you have to do is go to Insert > Legend, right?  Are there any special settings to let the print service know it can adjust its contents?
0 Kudos
JohnGravois
Frequent Contributor
so your adapted app works with the SampleServer6 layout templates with legends, but when pointing at your own custom template, not even the title displays, correct?

i don't recall doing anything special when i created and published my own custom templates, but i think i started by modifying the ones that come preinstalled.  here's a screenshot of the property page for mine for you to compare and contrast.

the cool thing is you can make changes to the MXD on the fly and see them in print output without touching your service.

[ATTACH=CONFIG]19636[/ATTACH]
0 Kudos
MarkHoover
Occasional Contributor II
Bingo, that was it.  Those two checkboxes weren't turned on in my Legend.  Now it works.  Thanks for your help!
0 Kudos
JohnGravois
Frequent Contributor
excellent 🙂
0 Kudos
CesarPiovanetti
New Contributor II
Great information!!  solved one of my problems.

open question:

What if i want to print my legend on a separate page?  My app has over 50 layers. and i don't want to compromise my current map template. how could we print the legend on a separate page?


Thoughts???

Thanks in Advanced!!
MiriamBrockmann
Occasional Contributor

Hi Cesar!

Have you find a way to print the legend seperatly? I face the same Problem right now and haven't find any solutions yet.

Regards, Tiki

0 Kudos