Using printTask to create jpg/png gives error

414
3
Jump to solution
05-10-2019 02:09 PM
IsraelBrewster
New Contributor

Using ArcGIS version 3.23, I am attempting to follow the directions in this question save map as image using javascript using utility.arcgis.com in order to create an image of my current map. Unfortunately, when I try running that code, calling printTask.execute just results in a "TypeError: undefined is not an object (evaluating 'this._url.query')" error.

My code is virtually identical to that post, other than changing the references to the map, etc to actually point to my map instances.

Is there a better way to save an image of a map? Something not so convoluted? Or, if not, how can I fix this issue? For what it's worth, I've also looked at the client side option listed in that thread, but being that it is written in typescript, and the compiled version gives an error (not to mention all the errors about missing requires when compiling), I haven't been able to get that to work either.

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Hi Israel,

For 3x, the Print dijit is the easiest way to print an image of the map. You can define the format (e.g. jpg/png) using the PrintTemplate.

3.28 Sample

https://developers.arcgis.com/javascript/3/jssamples/widget_print_webmap.html

If you're able to use the 4x version of the API, which I highly recommend, then you can also use the Print widget or the MapView.takeScreenshot() method.

4.11 Sample

https://developers.arcgis.com/javascript/latest/sample-code/widgets-print/index.html

View solution in original post

0 Kudos
3 Replies
Noah-Sager
Esri Regular Contributor

Hi Israel,

For 3x, the Print dijit is the easiest way to print an image of the map. You can define the format (e.g. jpg/png) using the PrintTemplate.

3.28 Sample

https://developers.arcgis.com/javascript/3/jssamples/widget_print_webmap.html

If you're able to use the 4x version of the API, which I highly recommend, then you can also use the Print widget or the MapView.takeScreenshot() method.

4.11 Sample

https://developers.arcgis.com/javascript/latest/sample-code/widgets-print/index.html

0 Kudos
IsraelBrewster
New Contributor

Thanks. Using the print dijit works - sometimes. Generally I have to click the button two or three times before I get the Printout link, the rest of the time I just get timeout errors. This is using sampleserver6.arcgisonline.com.

I'd like to update to 4, but at first glance it looks like that would be a fairly major overhaul.

0 Kudos
Noah-Sager
Esri Regular Contributor

Correct, upgrading to 4x would be a rewrite of your application(s). But something worth considering for future projects.

I would not recommend using sampleserver6 for production applications. That service is primarily used for samples and testing. The AGO utility print service or your own hosted print service would be recommended.

Task: Export Web Map Task 

0 Kudos