PrintTask - Custom Legend

217
2
09-15-2020 12:37 PM
AndrewMurdoch1
Occasional Contributor II

Good Day

Is there a way to build in a custom legend with the Print Task output?  Assuming I have the following output

Can I have only one set of data per geometry shown in the legend, without restructuring how our data is broken down by feature layer?  Ideally I'd want to change the legend based on the condition at the time the printMap function is executed.


My Print Code:

printMap() {
  const printTask = this.PrintTask({
    url: 'https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task'
  });

  const template = new this.PrintTemplate({
    format: 'jpg',
    layout: 'a4-landscape',
    layoutOptions: {
      titleText: '',
      authorText: 'Infrasol'
    }
  });

  const params = new this.PrintParameters({
    view: this._view,
    template: template
  });

  this.printProgress = true;
  printTask.execute(params).then( (result) => {
    this.printProgress = false;
    window.open(result.url);
  }, (err) => {
    this.printProgress = false;
    console.log('ESRI Print Task Error: ', err);
  });
}


Thanks

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

The printed legend is based on the ArcMap or ArcGIS Pro published template (hosted in ArcGIS Enterprise or ArcGIS Online), feature visibility, and the legend layer properties LegendLayer | ArcGIS API for JavaScript 4.16 

So I don't think we have an OOTB method to achieve what you're looking for. Perhaps others in the community have a workaround for this.

AndrewMurdoch1
Occasional Contributor II

Okay, I have a potential workaround on my end but it's less then ideal.  If there's no simple / non-hackish ways to pull this off then I see about editing my code.

Thanks!