AnsweredAssumed Answered

UniqueValueRenderer, Legend, and Print Task

Question asked by xuejinruan on Apr 16, 2015

I am trying to use ArcGIS Server javascript API UniqueValueRenderer to create a thematic map for a feature service. In the feature service, I have a field called "MapCode", say, with value '01', '02', '03', '04', '05', '06' '07'....... My external code dynamically generate group membership info for each MapCode value, for example:

'group1' includes '01', '02' '03'

'group2' includes  '07', '04'

'group3' includes '05', '06'

 

When I create the thematic map, the rendering field is 'MapCode' for the feature service. All the 'MapCode' from the same group will be rendered the same. In the legend,   I want to consolidate them and label with group name.

So the code is something like the following:

 

renderer = new UniqueValueRenderer(null, 'MapCode');

 

 

renderer.addValue(

                                   {

                                       value: ‘01’,

                                       symbol: symbol1

                                       label: ‘Group 1’

                    })

renderer.addValue(

                                   {

                                       value: ‘02’,

                                       symbol: symbol1

                                       label: ‘Group 1’

                    })

renderer.addValue(

                                   {

                                       value: ‘03’,

                                       symbol: symbol2

                                       label: ‘Group 2'

                    })

......

When I create the thematic map, it looks like the way I want. It is smart enough to consolidate the legend and  only show one entry for each symbol/label combination:

However, when I use PrintTask to print the map, the legend repeats, as it shows one entry for each unique 'MapCode' value.

 

Is there a way to modify the config or the parameters so that the legend in the Printed PDF is consolidated? I tried to intercept the "Web_Map_as_JSON" string before it is sent to the server, but could not figure out which parameter should be modified in order to get the expected output.

 

Thanks,

 

Xuejin

Outcomes