AhammadaliPK
AhammadaliPK

Reputation: 3548

What is the difference between esri print task and export web map

While taking screenshot of the current map using arcgis JavaScript, I could see that we have two ways to take the screenshots.
I could see same question asked here

  1. using /export of url
    enter image description here

  2. using print task api

        var printTask = new esriLoader.PrintTask(PrintTaskServiceUrl);
        esriLoader.Config.defaults.io.proxyUrl = proxyUrl;
        esriLoader.Config.defaults.io.alwaysUseProxy = true;
        var template = new esriLoader.PrintTemplate();
        template.exportOptions = {
            width: 1015,
            height: 633,
            dpi: 96 // if 200 ,map image will get good quality
        };
        template.format = "JPG";
        template.layout = "MAP_ONLY",
        template.preserveScale = false;
        template.showLabels = true;
        template.showAttribution = false;
    
        template.layoutOptions = {
            "legendLayers": [], // empty array means no legend
            "scalebarUnit": "Miles",
            "copyrightText": "<div>xxx</div>",
        }
        var params = new esriLoader.PrintParameters();
    
        params.map = map;
        params.template = template;
    
        printTask.execute(params, success, error);
    

So, what is the difference between these 2 methods?

Upvotes: 1

Views: 2886

Answers (3)

ko la
ko la

Reputation: 431

Answering the original question now.

  1. The Export Map REST end point is specific to a MapServer service and allows for producing a service image for given extent, specified layers, spatial reference, etc.

  2. Ultimately, PrintTask sends request to Export Web Map Task REST end point. Export Web Map Task is an interface for producing a map image, possibly with multiple services present and graphics, per provided Web_Map_as_JSON parameter. It also provides an option to surround the map image with a layout, predefined as an ArcGIS template (stored on the server). For example:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task/execute

After executed, the value of url in provided results is reference to the map image.

Export Web Map Task interface results

Note: Web Map as JSON parameter can be observed in browser's developer tools after PrintTask request is sent by the API. In this case, it is taken from ESRI's Print Dijit example: (cannot post another link)

Upvotes: 1

ko la
ko la

Reputation: 431

Disclaimer: I just joined and don't have reputation to comment; hence I have to post it as an answer to original question, which following is not.

Is there any advantage when using REST API directly or vice versa?

As T Kambi stated, using PrintTask, if available, is easier. Accessing Export Web Map Task REST end point directly may be beneficial in some cases, for example:

  • Web_Map_as_JSON parameter needs to be modified before request is sent to the Export Web Map Task Geoprocessing service. For example, resources not present in the map need to be added, layers' visibility needs to be changed, tokens for secured services need to be supplied, etc.
  • The request for map image is sent from outside of ArcGIS API for JavaScript environment. There may be no actual map and one only wants to use ArcGIS Server capabilities to fuse services' images and utilize a Layout Template.

The Export Web Map task may be accessed either from client or server side. In the latter case, a kind of "Print Task proxy" may help with printing secured services; for example, eliminate need for custom printing service in applications utilizing Long-lived Tokens.

Upvotes: 1

T Kambi
T Kambi

Reputation: 1387

  1. Is the REST API provided by ArcGIS Server to generated map images.
  2. Is the Javascript object with in ArcGIS JavaScript SDK.

The PrintTask will use the Export Web Map Task from REST api to generate the map image. PrintTask provides a simple way of creating images. On the other hand, if you want to use the REST API directly you can do so, by using esri\request object, but you would have to generate all the required parameters as described by the API.

Upvotes: 2

Related Questions