Layers in map application not showing - PrintTask Javascript

614
3
04-26-2013 10:17 AM
JustinShepard
Occasional Contributor II
I have a map application built using JavaScript api 3.3 and added a print function based on the esri tutorial  http://resources.arcgis.com/en/help/main/10.1/index.html#//0057000000mr000000. The high points: 1) the code runs and creates a pdf 2) it is using the mxd that I specified for the template and 3) the pdf is zoomed to the extent from the map application.

The problem: None of the layers that I added in the map application are showing up in the pdf. This is the case for both the dynamic map service layers that are pulling in services from my ArcGIS Server and the basemap that I added. I did modify the tutorial to comment out removing service layers.

Does the print task require a proxy (both my dynamic services and geoprocessing service are coming from the same ArcGIS Server)? If so is that why my layers are getting dropped?
0 Kudos
3 Replies
JohnGravois
Frequent Contributor
the printTask has the same proxy prerequisites as anything else in the JavaScript API.  (they are necessary only when POSTing across domains when either the server or browser does not support CORS).

i dont think this is a very likely explanation for the selective lack of layers in your own application though.  if a proxy is needed, but not available, i would expect the entire request to fail.

what happens when you modify our published print widget sample to substitute your own service, does everything print properly?
0 Kudos
JustinShepard
Occasional Contributor II
When I use the print widget and point to Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task on my server then I get all of the layers. However, it does require the I use esri.config.defaults.io.proxyUrl = "/proxy"; which throws an error if I try to run any print service other than the Utilities/PrintingTools. So you're saying that I shouldn't need a proxy at all if all I'm using are services from my server (what if I add a basemap like streets in the map declaration)?

On a side note about the Utilities/PrintingTools, online it says that there are numerous templates and you can select the format. But I can't find a list of what the template names are or how to get it output to anything other than it's default png.
0 Kudos
JohnGravois
Frequent Contributor
the location of the resources in your webmap json don't determine whether a proxy is required.  the print request itself does.  if the url is to long to send as a GET, and the resulting POST needs to travel across domains, a proxy will probably be necessary.

with regard to valid template values and output file types, the print service itself should be exposing what parameters are allowed.
0 Kudos