1

I'm trying to print a Map asynchronously using the ArcGIS printing tools. I'm successfully able to print the map using any template other than "MAP_ONLY". When i use "MAP_ONLY" template i get this error : ERROR 001305: Missing or invalid 'exportOptions' property in WebMap; cannot derive a size for the output image. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task). I'm not sure if there is a way to include the export options in the web map Json object. Here is the code:

 var initPrintParameters = function() {
        var temp = new PrintTemplate();
        temp.exportOptions = {
          width: dpi * 10, //3000, //960, //840,
          height: (20 * dpi) / 3, //640, //560,
          dpi: dpi
        };

        temp.format = "PNG32";
        temp.layout = "MAP_ONLY";
        temp.preserveScale = true;
        temp.showAttribution = true;

        printParameters = new PrintParameters();
        printParameters.format = "png32";
        printParameters.template = temp;
        printParameters.map = map;
        printParameters.outSpatialReference = map.spatialReference;
        printParameters.async=true;
    };

  var exportMapAtCurrentExtent = function() {
    printTask = PrintTask(printTaskUrl);
    initPrintParameters();
     var jsonMap = JSON.toJson(printTask._getPrintDefinition(map,printParameters));     
    var printLayout={  
      Web_Map_as_JSON: jsonMap,  
      Format: "PNG32",  
      Layout_Template: "A3 Landscape"
    };
      gp.submitJob(printLayout,gpJobComplete, gpJobStatus,gpJobFailed);
  };

  var gpJobComplete=function(jobInfo){
      console.log("Job Complete");
      console.log(jobInfo);
      gp.getResultData(jobInfo.jobId,"Output_File",getResultUrl);
  };

  var getResultUrl=function(result){
      console.log(result.value.url);
  };

  var gpJobStatus=function(jobInfo){
      console.log("Job Status");
      console.log(jobInfo);
  };

  var gpJobFailed=function(jobInfo){
      console.log("Job failed");
      console.log(jobInfo);
  };

In the above snippet the 'Layout_Template' is "A3_Landscape" and this works as i'm guessing the size of the map is predefined. I need to way to use the "Map_Only" template so that i can change the size of the map.

2

I manually added the export options to the Web map json. Below is the code snippet.

 var exportMapAtCurrentExtent = function() {
    printTask = PrintTask(printTaskUrl);
    initPrintParameters();
     var jsonMap = JSON.toJson(printTask._getPrintDefinition(map,printParameters)); 
     jsonMap=jsonMap.replace(/\}$/, '');
     jsonMap=jsonMap+",'exportOptions':{'outputSize':[3000,2000],'dpi':300}}"   ;    
     var printLayout={  
       Web_Map_as_JSON: jsonMap,  
       Format: "PNG32",  
       Layout_Template: "MAP_ONLY"
     };
      gp.submitJob(printLayout,gpJobComplete, gpJobStatus,gpJobFailed);
  };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.