Question regarding LegendOptions and SubLayerIds

2104
4
01-10-2013 02:33 AM
JohanCarlsson
Occasional Contributor
Hi!

I'm working with the source code for the PrintTool that was delivered with the new API. I've modified it so that the user may choose what to display in the legend. However, I don't fully understand the way layers in LegendOptions work.

The picture "sublayers.png" below shows which layers I've selected to be displayed in the legend. My problem is that I'd only like to display the legend of subLayerId 18, but to do that I have to include subLayerId 15. When I do this, all sublayers belonging to subLayerId 15 are included in the legend, even though I don't pass their Id's to LegendOptions. Including only subLayerId 18 yields no results.

How would I go about achieving this? The legend easily becomes  too cluttered if I can't control it below that level.

Any help would be greatly appreciated!
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
I'd only like to display the legend of subLayerId 18, but to do that I have to include subLayerId 15.


No you should just give 18.

When I do this, all sublayers belonging to subLayerId 15 are included in the legend, even though I don't pass their Id's to LegendOptions.

That's normal, 15 being a group layer, if you give it as input all sublayers will be included in the legend as well.

Including only subLayerId 18 yields no results.


That's not normal.
What happens if you display only this layer in the map and you export the map with the default parameter (i.e without setting LegendOptins by yourself)? You should only see this layer in the legend and then you can use fiddler to check the sublayers sent to the server.
0 Kudos
JohanCarlsson
Occasional Contributor
I've hidden all layers except "�?rende" and the subLayer 18.
This is the output from Fiddler:

"legendOptions":{"operationalLayers":[{"id":"516048601b63414e88aa25587f5a11df"}]


That is the Id of the layer "�?rende". All subLayers except 18 are hidden but still visible in the legend.

EDIT:
Including only subLayer 18 results in no parameters passed to LegendOptions. I misinterpreted your text, sorry.
"legendOptions":{"operationalLayers":[]}
0 Kudos
JohanCarlsson
Occasional Contributor
I tried hardcoding the sublayers that should be included. They then show up in Fiddler but not in the legend.

Displays everything below Id 15:
{"operationalLayers":[{"id":"516048601b63414e88aa25587f5a11df","subLayerIds":[15,18]}]}


Displays nothing:
{"operationalLayers":[{"id":"516048601b63414e88aa25587f5a11df","subLayerIds":[18]}]}


Disabling my own code for LegendOptions and only displaying visible layers (default) yields the same results, except selecting subLayerId 15 includes Ids 16 through 19 as you said. As soon as I supply subLayers it seems like the legend wont work. Working with a layer that doesn't have grouped sublayers works (see the image).

No clues to what might be wrong? Am I doing something thats not correct or is it a problem with the service I'm working against?

Edit: Sorry, the top layer in the left image should be checked too for it to be correct.
0 Kudos
ArneDahlman
New Contributor III
I think this must be a bug.

If a layer is inside a group (where thare are other visible layers), it is not possible to include only that one layer to the legend.


Thanks
Arne Dahlman
0 Kudos