Select layers to print in PrintTask

02-18-2021 01:48 AM
New Contributor III


With JS API 4.18, I've built an app that allows the user to inspect raster data. On the same area, several raster layers (ImageryLayer) are available. The user can draw graphics on the map in a graphicLayer. For output, the need is to provide the user with one map for each ImageryLayer, at the extent of the drawn graphics.

Saying there are 10 ImageryLayer, the user would get 10 mapImages, each with one layer and drawn graphics.

I'm aware of the PrintTask that I wanted to use, but all my ImageryLayers are available in the map, and after searching the API and internet, I've not found any way to specify the layers I want to be printed, and not print all of them.

Is there any way to do that, or should I try to filter the JSON before sending it to the Export Web Map Task ?

Thanks !

0 Kudos
1 Reply
New Contributor III

Well for the moment I can access the JSON generated by the PrintTask with

printTask._getPrintDefinition(<PrintParameters>, <PrintTemplate>)

I can then try to modify it before sending it to the Export WebMap Service. At least the geometries in my graphicLayers are all serialized thanks to this method !