Print Widget 3.1 Question

3314
13
12-18-2012 11:51 AM
JasonNielsen
Occasional Contributor
I'm trying to exclude some layers from my print layouts in Flex viewer 3.1. I see that in the new documentation you can use the: <excludelayerfromlegend>thelayername</excludelayerfromlegend> to remove the entire map service. My question is how to only eliminate 1 or 2 layers in a mapservice from the legend? I'm using ArcGIS 10.1

Here are some examples of things i have tried but nothing seems to work. Perhaps somebody has tried to do this already and can explain to me what i'm doing wrong.

<excludelayerfromlegend>CityAnnexations</excludelayerfromlegend> --> this will remove all of this mapservice from the legend. But NOT all of the time. Sometimes it will randomly show up on the layout. After cleaning my temp files and even restarting my pc.

I've tried the following with no luck to exclude only certains layers in a map service. Can somebody from the ESRI team give me a correct example on how to specifically exclude a layer from a map service with the print widget, or if it is possible to do in 3.1.

<excludelayerfromlegend>CityAnnexations</excludelayerfromlegend>

<excludelayerfromlegend>PLSS Boundaries "1,3,4,5,6,7,8,9,10,11"</excludelayerfromlegend>


Also my images in the legend come out all weird with lines thru them and they should just be outlines with no fill for symbology.

the support team tried to assist me in this a few months back by changing the default printer on the server to have a paper size greater than anything you would print but that workaround does not work now and it is very frustrating.

Thanks,

Jason
Tags (2)
13 Replies
SarthakDatt
Occasional Contributor III

<excludelayerfromlegend>CityAnnexations</excludelayerfromlegend>    --> this will remove all of this mapservice from the legend. But NOT all of the time. Sometimes it will randomly show up on the layout. After cleaning my temp files and even restarting my pc.

I've tried the following with no luck to exclude only certains layers in a map service. Can somebody from the ESRI team give me a correct example on how to specifically exclude a layer from a map service with the print widget, or if it is possible to do in 3.1.


At 3.1, it is NOT possible to exclude a layer within a map service, if specified the whole map service would be excluded
0 Kudos
JasonNielsen
Occasional Contributor
At 3.1, it is NOT possible to exclude a layer within a map service, if specified the whole map service would be excluded


Okay that is good to know. Are there any plans to add this to a future release? Sounds like i'll have to reorganize some map services on my end then. Also any idea on why i get lines thru my legend features?
0 Kudos
SarthakDatt
Occasional Contributor III
Okay that is good to know. Are there any plans to add this to a future release? Sounds like i'll have to reorganize some map services on my end then.


Yes, we plan to add that as part of the next release. In the meantime, if you are working with the uncompiled version of the viewer, you can update the widget code to do the same:

private function getLegendOptions():LegendOptions
            {
                var result:LegendOptions = new LegendOptions();
                var legendLayers:Array = [];

                for each (var layer:Layer in hostBaseWidget.map.layers)
                {
                    if (layer.name.indexOf("hiddenLayer_") == -1 && !(layer is GraphicsLayer && !(layer is FeatureLayer)))
                    {
                        var isBaseMapLayer:Boolean = false;
                        for each (var baseMapLayer:Object in hostBaseWidget.configData.basemaps)
                        {
                            if (baseMapLayer.label == layer.id)
                            {
                                isBaseMapLayer = true;
                                break;
                            }
                        }
                        if (!isBaseMapLayer)
                        {
                            // filter the layer through the list of names of excluded layers.
                            var isExcludedLayer:Boolean = false;
                            for each (var excludeName:String in excludeLayersFromLegend)
                            {
                                if (excludeName == layer.id)
                                {
                                    isExcludedLayer = true;
                                    break;
                                }
                            }
                            if (!isExcludedLayer)
                            {
                                var legendLayer:LegendLayer = new LegendLayer();
                                legendLayer.layerId = layer.id;
                                if (layer is ArcGISDynamicMapServiceLayer && layer.name == "your dynamic mapservice")
                                {
                                    legendLayer.subLayerIds = ["ids of sublayers to be included"];
                                }
                            }
                        }
                    }
                }

                result.legendLayers = legendLayers;

                return result;
            }


See:
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/tasks/supportClasses/LegendLayer.ht...
0 Kudos
JacobBoyle
Occasional Contributor III
you get lines through your legend symbols because of this

http://support.esri.com/en/knowledgebase/techarticles/detail/40538
0 Kudos
MichaelVolz
Esteemed Contributor
Sarthak:

You replied to Jason's post by saying:

"Yes, we plan to add that as part of the next release. In the meantime, if you are working with the uncompiled version of the viewer, you can update the widget code to do the same:"

Does this answer mean this functionality will be available in FlexViewe 3.2?

Your response is greatly appreciated.
0 Kudos
SarthakDatt
Occasional Contributor III
Sarthak:

You replied to Jason's post by saying:

"Yes, we plan to add that as part of the next release. In the meantime, if you are working with the uncompiled version of the viewer, you can update the widget code to do the same:"

Does this answer mean this functionality will be available in FlexViewe 3.2?

Your response is greatly appreciated.


Yes we have every intention of adding it as part of 3.2.
0 Kudos
EricVenden
Occasional Contributor II
Good morning Sarthak

I am attempting to use the code you posted to modify our print widget in FV 3.1.
I updated the code in the ExportWebMapForm.mxml to include the additional "if" statement.
I put the name of the map service in quotes and the id's of the sublayers in quotes.

I compiled and tested it - and now I do not have a legend at all.

Could you assist?
Thanks for your time.
Eric V
Gurnee, IL
0 Kudos
BjornSvensson
Esri Regular Contributor
Just wanted to follow up and let everyone know that this has been fixed and will be part of the 3.2  release (see GitHub Issue #21).

FYI: if you want to see what other viewer code changes made it into 3.2, look at the 58 closed and verified issues for 3.2:
https://github.com/Esri/arcgis-viewer-flex/issues?labels=verified&milestone=1&state=closed
0 Kudos
JoshWhite
Regular Contributor III
This is a great enhancement, I do have a problem though, I was able to get some layers to be excluded but others wont work.  Here is a snippet from the config file:

<excludelayerfromlegend>Internal Webmap/0</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/1</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/5</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/12</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/30</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/50</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/51</excludelayerfromlegend>
  <excludelayerfromlegend>Internal Webmap/52</excludelayerfromlegend>

Layers 12-32 are all under the group Parcels in my mxd.  So Layer id 12 is that layer.  When I tried to do layer id 30, it didn't actually remove the layer from the legend, so I added 12 and of course that did eliminate 30 but I didn't really want to remove everything under 12.  Does that make any sense? An excerpt from my REST Services Directory is below. Layers 13-28 are all annotation layers.


[ATTACH=CONFIG]23560[/ATTACH]
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos