Legend customization with print service, using custom map template

7644
19
10-09-2015 11:09 AM
ZoeZaloudek
Occasional Contributor

This is similar to a question in another recent post of mine – but since this is dealing with generating maps using a print service, I figure it warranted a separate post.

I have a map that’s showing a feature layer.  The feature layer has been symbolized in the code using a class breaks renderer.  I’ve also set up custom map templates and a custom print service, to have control over the details of how an exported map will look.  There are two things that I’m having trouble figuring out: 

1 - In the exported map, the name of the feature class (also the layer name in the service) shows up in the legend…  I don’t want that there.  Interestingly, it does not show up in the Legend Dijit.  Just in an exported image.

includesflyrname.png

2 - I’d like to know if there is a way to force the legend to display multiple columns, since I have a portrait layout and only 3 or 4 classes will fit in one column before the legend goes off the page.  Is there a setting somewhere in the renderer that I can use?  Do I set that up in the custom mxd?  It is saved with no layers in it, so I'm not sure how any settings I make there would carry through to when it's used with the print service.

needhorizlegend.png

19 Replies
ZoeZaloudek
Occasional Contributor

Well, I have solved question number two, and it didn't even involve JavaScript.  I'm not sure how I missed this before. In my custom MXD, in the (blank) Legend's properties, on the Layout tab, there is a section in the lower right called Fitting Strategy.  I just checked the Fixed Frame box and then set the legend's available area (width/height) on the Size and Position tab.  Now the legend will make as many columns as it needs. 

Side note - I found that if the legend items still won't fit in the area, it will only show the title.  I spent a while trying to figure out why my legend was empty, until I figured out I just needed to make my legend area larger.LegendSettings.png

MichaelVolz
Esteemed Contributor

Do you know if the same behavior would exist in the legend if your layer was a dynamic mapservice and not a feature layer?  This would just be a test as I'm sure you need it to be a feature layer.

0 Kudos
ZoeZaloudek
Occasional Contributor

It seems like the answer is yes - this will work for both. 

Here's how the legend came out when one layer of my dynamic map service layer is showing:

_ags_5cd5244f4a9a420b829f3b8cc94e1e1f.png

MichaelVolz
Esteemed Contributor

Do you want the legend below the map the way you are showing it in the screenshot or would you rather have the legend on either the right or left side of the map?

0 Kudos
ZoeZaloudek
Occasional Contributor

In this case, I do want it on the bottom.  The image being created is only 6 inches wide by 8 inches tall (portrait).  I have another option set up as 8" wide x 6" tall (landscape) - for that one I just have the legend as one column on the right.

0 Kudos
TracySchloss
Frequent Contributor

I created a box for my legend in the lower corner of my template, but I wasn't sure what size to give the legend. How can you tell when it's still blank?  When I resize it, the word Legend just got bigger and bigger and it didn't seem right to stretch it until it filled the box I'd created for it.  I assume doing that would proportionally effect all the other text, yet to be populated once I apply the template for printing.

Is this resolved by turning on fitting strategy?  Then it wouldn't matter how big the word Legend was, because the fonts would all resize to fit?

0 Kudos
ZoeZaloudek
Occasional Contributor

I think so.  At least in my case, I'd originally noted the same as you... With no layers in the mxd, the legend only showed as the title word 'Legend', and setting it to be wider and taller only seemed to make the word bigger.  Once I checked that 'Fixed Frame' checkbox, I was able to set a width and height for my legend without the title getting larger.

LgndProp1.png

LgndProp2.png

0 Kudos
TracySchloss
Frequent Contributor

I have someone else who's coding against the printTemplate I authored, so I can't check this myself.  I was told that after I turned on the fitting strategy, the legend disappeared entirely off the page.  I wonder if it has to do with where the anchor point is.

0 Kudos
MichaelVolz
Esteemed Contributor

Tracy:

Do you have a large number of layers in the legend?  I would suggest having only 1 or 2 layers in the legend as a test and see if it still disappears.

From my experience, I had individual layers with many symbol classes that would disappear from the legend because the symbology for the entire layer would not fit in the legend box.

I have a bug open with ESRI where the shrink contents to fit frame in ArcGIS Server does not behave the same way as it does in ArcMap.  I can post the NIM if you are interested.

0 Kudos