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]
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; }
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.
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.
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; }
At 3.1, it is NOT possible to exclude a layer within a map service, if specified the whole map service would be excluded
<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.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.