Select to view content in your preferred language

JS 4.3 PrintTask - MapView.rotation

652
1
Jump to solution
04-11-2017 01:41 PM
JordanBaumgardner
Frequent Contributor

I need to set the rotation on a print task. Anyone know how? I'm about to hack the bloody thing and make the call myself, but there must be a better way. The WebMap JSON is simply missing the Rotate attribute. I just can't seem to intercept it before it chucks it up to my server. Any thoughts are greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
JordanBaumgardner
Frequent Contributor

This works but there must be a better way.

*Esri - your Web Map as JSON in _setPrintParams(a) doesn't pick up rotation.

I subclass the EsriPrintTask and insert the rotation in the string-a-fied map json. I probably should insert it with something other than a string replace, but this works for now.

var CustomPrintTask = EsriPrintTask.createSubclass({
   execute: function (a, b) {
      internalPrintPrams = this._setPrintParams(a);
      internalPrintPrams.Web_Map_as_JSON = internalPrintPrams.Web_Map_as_JSON

         .replace(/mapOptions":{/gi,'mapOptions":{"rotation": -' + a.view.rotation.toString() + ',');
      return this._geoprocessor["async" === this.mode ? "submitJob" : "execute"](internalPrintPrams, b)
         .then(this._handleExecuteResponse)
   }
});

me.myPrintTask = new CustomPrintTask();
me.myPrintTask.url = printUrl;
me.myPrintTask.mode = "async";

me.myPrintTask.execute(prntPrms).then().otherwise();

How are you guys getting that cool "code" formatting with the line numbers?

And, do we really have to obfuscate the SDK? Dang, it makes debugging hard in the late evening.

View solution in original post

0 Kudos
1 Reply
JordanBaumgardner
Frequent Contributor

This works but there must be a better way.

*Esri - your Web Map as JSON in _setPrintParams(a) doesn't pick up rotation.

I subclass the EsriPrintTask and insert the rotation in the string-a-fied map json. I probably should insert it with something other than a string replace, but this works for now.

var CustomPrintTask = EsriPrintTask.createSubclass({
   execute: function (a, b) {
      internalPrintPrams = this._setPrintParams(a);
      internalPrintPrams.Web_Map_as_JSON = internalPrintPrams.Web_Map_as_JSON

         .replace(/mapOptions":{/gi,'mapOptions":{"rotation": -' + a.view.rotation.toString() + ',');
      return this._geoprocessor["async" === this.mode ? "submitJob" : "execute"](internalPrintPrams, b)
         .then(this._handleExecuteResponse)
   }
});

me.myPrintTask = new CustomPrintTask();
me.myPrintTask.url = printUrl;
me.myPrintTask.mode = "async";

me.myPrintTask.execute(prntPrms).then().otherwise();

How are you guys getting that cool "code" formatting with the line numbers?

And, do we really have to obfuscate the SDK? Dang, it makes debugging hard in the late evening.

0 Kudos