Select to view content in your preferred language

PrintTask uncaught TypeError: Cannot read property 'query' of undefined

1615
3
Jump to solution
08-16-2016 08:25 AM
Alexwang
Frequent Contributor

Hello I was able to generate a thumbnail image using PrintTask from a WAB widget via http://mycomputer:3344/webappviewer/?config=sample-configs/config-demo.json. But after I added the widget to one of my apps using WAB dev edition. i got an error below

Not sure why it worked through the custom widget testing url but didn't work after I added it to my application. Can you please help?

_printTask: null,
_printTaskParams: null,
_thumbnailHeight: 200,
_thumbnailWidth: 200,
_thumbnailDpi: 96,
_thumbnailFormat: 'PNG32',
_templateLayout: "MAP_ONLY",
_preserveScale: false,
_showAttribution: false,
_exportWebMapTaskUrl: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%2...',

_initPrintTask: function(){
      this._printTask = new PrintTask(this._exportWebMapUrl);
      var template = new PrintTemplate();
      var params = new PrintParameters();

template.exportOptions = {
   width: this._thumbnailWidth,
   height: this._thumbnailHeight,
   dpi: this._thumbnailDpi
};

template.format = this._thumbnailFormat;
template.layout = this._templateLayout;
template.preserveScale = this._preserveScale;
template.showAttribution = this._showAttribution;

params.map = this.map;
params.template = template;

        this._printTaskParams = params;
},

_createThumbnail: function(){

this._printTask.execute(this._printTaskParams, lang.hitch(this, function(result){
      this._storeThumbnailUrl(result.url);
}));

},

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

   You have to edit your ArcGIS Servers "Site" page and find the output directory and change the max file age (default 10 minutes).

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

   You included some code and a screen capture of the error but that is still not enough for me to figure out the error. Can you provide more?

0 Kudos
Alexwang
Frequent Contributor

Thanks Robert. My fault, I used the wrong name for the PrintTask url. I was able to make it work now. 

Another question i observed was that the ArcServer GP service keeps the map images only for a short time. Can I change somewhere on ArcServer side to keep the thumbnail images longer? Basically my widget uses a reference to link to these thumbnail images. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   You have to edit your ArcGIS Servers "Site" page and find the output directory and change the max file age (default 10 minutes).