I'm using Robert's Scheitlin's TOC/Legend widget (I'm using the version that is posted onhttp://www.arcgis.com/home/item.html...9f945ae0db7ce8 - I downloaded it about 10 days ago, so I'm not sure if there's a more current version) in my web map. The widget works just fine, but I have come across an issue when exporting the web map to a PDF file, and I'm not sure if the issue is related to the TOC/Legend widget or to the Export Web Map tool. So I thought I'd post this here in case anyone has some insight on the issue.
First, some background. I've created a web mapping app (using ArcGIS 10.1 and Flex 3.1) and added the Print widget to the map so that users can export/print their web map. I also created my own custom map template MXD files to use in place of the default map templates that are provided in ArcGIS.
My custom map templates have a dynamic legend that shows only layers and features that appear in the viewed map extent. Everything works as expected in my map template MXD. As I zoom out, more different types of features are shown in the map, with their corresponding symbols being added to the dynamic legend. Likewise, when I zoom in to a smaller area, there are fewer different types of features, and the dynamic legend has correspondingly fewer symbols. So that all works just fine in my MXD template.
However, when I use the Print widget (which uses the Export Web Map tool) in my web map to export the currently viewed map to a PDF file, the legend in the resultant PDF actually has two legends: one legend is coming from Robert's TOC/Legend widget, and the other legend is the dynamic one from my map template MXD. You can see this in the attached file 1-Correct_map--Wrong-Legend.jpg. This isn't what I need - I need only the dynamic legend from my MXD.
In troubleshooting the issue, in my web map I turned off visibility for all layers (except the raster base map) and exported to PDF. The resultant PDF correctly shows only the dynamic legend from my MXD template, but of course with all the layers turned off in the web map, the map is blank, except for the raster base map (see attached file named 2-Wrong-Map--Correct-Legend.jpg). So what I need is the map from #1(which comes from the current view in the web map) and the dynamic legend from #2(which comes from my MXD template). I used #1 and #2 to create a mock-up in Photoshop that shows what I want my web-map-exported-PDF file to look like (see attached file named 3-Desired-Result.jpg - this exactly matches my MXD template).
I'm not sure how Robert's TOC/Legend widget and the Export Web Map tool interact with each other. But logically it seems that one of two scenarios is taking place:
Scenario 1 Robert's TOC/Legend widget is controlling the action and passing it's legend to the Export Web Map tool, which in turn adds it to the dynamic legend that exists in the MXD template. If this is the case, then is there a way to have Robert's TOC/Legend widget suppress the sending of its legend to the Export Web Map tool?
--or--
Scenario 2 The Export Web Map tool is controlling the action and requesting the current web map legend, which is dutifully supplied by Robert's TOC/Legend widget. If this is the case, is there a way to tell the Export Web Map tool to not request the legend from the web map, and instead use only the dynamic legend from the MXD template?
So, any thoughts on how I can achieve the desired web-map-exported-with-a-dynamic-legend-PDF result?
I have never heard of this occurring in connection with my widget. Have you removed my widget to see if after its removal the export is the same or not?
Ok, I've done some sleuthing and I'm about 99.99999999% certain that the issue is not with your TOC/Legend widget. It instead appears to be a function of the Export Web Map tool which utilizes the Flex 3.1 PrintTask.
The LegendOptions help page states, "To specify that no layers will be included in the legend, set legendLayers to an empty array."
Great. That sounds exactly like what I need to do. But not being a Flex expert, I have no idea where or how to "set legendLayers to an empty array." I purchased Adobe Flash Builder a couple of days ago but have not yet installed it. I assume that is the program I need to use in order to set legendLayers to an empty array, is that correct?
I'm a newbie at all this Flex stuff. Can you point me in the right direction?
Thanks for that - it was exactly what I needed. I put the <excludelayerfromlegend> tag in my Print widget XML and it solved the problem. My exported PDF is now exactly what I want.