Select to view content in your preferred language

Export Web Map

1315
2
06-19-2014 07:05 AM
deleted-user-yA_w_FC9FKe5
Deactivated User
Anyone have a good example of a sample that uses the Export Web Map task but allows the users the ability to select if they want to do pdf/jpeg etc ..   Having trouble finding anything like that.

Also if I am using this service on the same web server as my arcgis server behind our firewall (big company) do I need to worry about proxy server?  I can use this service with the Flex API without having to worry about proxy server stuff.  


Getting these errors though.  Do I need to require anything.  I require - "esri/dijit/Print"
LOG: esri.config.defaults.io.proxyUrl is not set.
LOG: Error: esri.config.defaults.io.proxyUrl is not set.
Error: esri.config.defaults.io.proxyUrl is not set. 
SCRIPT5022: No region setting for fpMeasurement


I thought this would work:


function Print(){
alert("Found Printing Start");
   var printUrl = "http://myserver:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

//REST URL:  http://myserver:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer
//SOAP URL:  http://myserver:6080/arcgis/services/Utilities/PrintingTools/GPServer

        //Set up print stuff
        var printTask = new esri.tasks.PrintTask(printUrl);
        var params = new esri.tasks.PrintParameters();
        var template = new esri.tasks.PrintTemplate();

        params.map = map;
 

alert("Found Mark 1");

 template.exportOptions = {
            width: 595,
            height: 842,
            dpi: 96
        };
  template.format = "PDF"
        template.layout = "Letter ANSI A Landscape";
        template.preserveScale = false;

alert("Found Mark 2");
        params.template = template;

alert("Found Mark 3");
        //dojo.connect(map, "onLoad", function() {//Fire the print task
        printTask.execute(params, printResult, printError);
        setTimeout(function(){printTask.execute(params, printResult, printError);},2500);
alert("Found Mark 4");
}; 
 
    function printResult(result){
        console.log(result.url)
    }
    function printError(result){
        console.log(result);
    }
0 Kudos
2 Replies
KeithGanzenmuller
Frequent Contributor
Michael,
   Unfortunately I am not writing with an answer but the very same question, same basic setup as you state but when I go to retrieve the templates I get the proxy not set error.
   Did you ever find a solution? I can manually populate the templates but would rather do it based on retrieving them from url

Keith
0 Kudos
NathanaelVaughan
Emerging Contributor
You need to set your proxy server in code a la:

esri.config.defaults.io.proxyUrl = 'http://..../proxy.ashx';


If you don't have a proxy set up on your webserver, you need to add one. There are instructions here:

https://developers.arcgis.com/javascript/jshelp/ags_proxy.html - this may take some trial and error on your part if you haven't set one up before. Google for help testing.

This is pre-AMD code, but hopefully it helps - it won't tell you how to solve your proxy issues (which are essentially network related), but it is an example of dynamically pulling the options. There are two selections: export options (png, jpg, pdf, etc.) and layouts.

Hopefully it helps.

printRequest = esri.request({
                              url: "http://.../rest/services/Geoprocessing/WebMapPDF/GPServer/Export%20Web%20Map",
                              content: { f: "json" },
                              callbackParamName: "callback",
                              handleAs: "json"//,
                          });

                          printTypes = new Array();
                          layoutTypes = new Array();

                          printRequest.then(
                              function (response, input) {
                                  // load printType list
                                  //printTypes, layoutTypes
                                  for (var i = 0; i < response.parameters[2].choiceList.length; i++) {
                                      printTypes.push(
                                          {
                                              label: response.parameters[2].choiceList,
                                              value: response.parameters[2].choiceList
                                          });
                                  }
                                  // load printLayout list
                                  for (var i = 0; i < response.parameters[3].choiceList.length - 1; i++) { // use length -1 to omit "MAP_ONLY" option
                                      // Build normal name of print option
                                      layoutName = response.parameters[3].choiceList;
                                      layoutTypes.push({ label: layoutName, value: response.parameters[3].choiceList });
                                  }
                                  select = dojo.byId("printExportType");

                                  if (dojo.byId("printButton") == undefined || dojo.byId("printButton") == null) {

                                      select = new dijit.form.Select(
                                          {
                                              id: "printExportType",
                                              //name: "printExportType",
                                              options: printTypes,
                                              value: printTypes[0].value,
                                              onChange: function () {
                                                  printTemplate.format = dijit.byId("printExportType").get("value");
                                                  dojo.byId("printButton").textContent = "Generate " + dijit.byId("printExportType").get("value");
                                              }
                                          });
                                      dojo.place(select.domNode, dojo.byId("toolInput"), "last");

                                      // Create combo button to select template
                                      select = new dijit.form.Select(
                                          {
                                              id: "printLayoutTemplate",
                                              name: "printLayoutTemplate",
                                              options: layoutTypes,
                                              value: layoutTypes[1].value,
                                              onChange: function () {
                                                  printTemplate.layout = dijit.byId("printLayoutTemplate").get("value");
                                              }
                                          });
0 Kudos