Currently, it works partly:
1) We created mxd with all layers
and set "Legend properties"->"General" check box on "Only display layers that are checked on in Table Of Contents" -
and set "Items" Only show classes visible in current extent
2) the code is now
template2.layoutOptions = {
"titleText": title,
"authorText": author,
"copyrightText": "Any copyright",
"legendLayers": [],
"scalebarUnit": "Miles",
};
it works partly:
1) OK - when change "display layers that are checked on in Table Of Contents" - it changes legend layers accordingly.
2) OK - it shows only visible (current extent) features symbology in the legend
3) NOT OK - it does not change visible sublayers: example:
"address_points" has 3 sublayers (the same source but different symbology):
- "show by population"
- "show by year"
- "show by update_time"
We expect when user change sublayer it will show in the legend (printed map) accordingly.
But it only takes first every time.