Select to view content in your preferred language

Print Widget 3.1 Question

3806
13
12-18-2012 11:51 AM
JasonNielsen
Regular 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
DanielJohns
Frequent Contributor
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]


I'm having the same issue with layers being grouped (inside of a group). I was initially hoping it was just the way I had the XML configured, but that doesn't appear to be the case.

Does anyone know of a way to include the child layers for the subgroups? I have Sewer Layers (group) -> Gravity Main (group) with two individual sublayers.

Thank you

            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;
                            var excludedSublayers:Array = [];
                            for each (var excludeName:String in excludeLayersFromLegend)
                            {
                                if (excludeName == layer.id)
                                {
                                    isExcludedLayer = true;
                                    break;
                                }
                                else
                                {
                                    const index:int = excludeName.indexOf("/");
                                    if (index != -1)
                                    {
                                        const layerName:String = excludeName.substring(0, index);
                                        const sublayerId:Number = Number(excludeName.substring(index + 1));
                                        if (layerName == layer.id)
                                        {
                                            excludedSublayers.push(sublayerId);
                                        }
                                    }
                                }
                            }
                            if (!isExcludedLayer)
                            {
                                var legendLayer:LegendLayer = new LegendLayer();
                                legendLayer.layerId = layer.id;
                                if ((layer is ArcGISDynamicMapServiceLayer || layer is ArcGISTiledMapServiceLayer) && excludedSublayers.length)
                                {
                                    var includedSublayers:Array = [];
                                    const layerInfos:Array = layer is ArcGISDynamicMapServiceLayer ? ArcGISDynamicMapServiceLayer(layer).layerInfos : ArcGISTiledMapServiceLayer(layer).layerInfos;
                                    for each (var layerInfo:LayerInfo in layerInfos)
                                    {
                                        if (excludedSublayers.indexOf(layerInfo.layerId) == -1)
                                        {
                                            includedSublayers.push(layerInfo.layerId);
                                        }
                                    }
                                    legendLayer.subLayerIds = includedSublayers;
                                }
                                legendLayers.push(legendLayer);
                            }
                        }
                    }
                }

                result.legendLayers = legendLayers;

                return result;
            }
0 Kudos
JoshWhite
Honored Contributor
I've had so many issues with the legends, I pretty much just exclude everything.  It is so inconsistent with the layers that it shows that it doesn't do me much good.  If somebody needs a map with a proper legend/layout, I'll just make them one in ArcMap.
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
BartBajek
Emerging Contributor
Hi Everybody,

I have a similar problem but still slightly different. Does anybody know how to change the appearance of the legend? I use a custom template to print and my legend just gets too big (well the symbols and the font in the legend is just too big). Any idea on how to get the legend being dynamic in terms of size? Just as an example I have an A4 mxd Template and when I print from the WebApp it just returns a legend far too big for a A4 size. Any possibility of changing this?
0 Kudos
TristanKnowlton
Frequent Contributor
Bart,

I added a feature class to my custom map layout.  I then made it have no color so that it does not show up in the data frame in thecustom layout when printing from the print widget.  Then add the feature class to the legend.  In legend properties, items tab, hit the select all button.  Then change the font and size to what ever you wish.  At this point, that feature class will show up in the legend when printing from the print widget.  You then need to change the font color to "No Color."  I was able to reduce the size of my legend this way.  On the "Layout" tab in the legend properties you can also change the gap distances and those help as well. 


Darryl
0 Kudos