esri打印任务和导出网络地图有什么区别

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

在使用arcgis截取当前地图时JavaScript,我发现我们有两种截屏方法。
I could see same question asked here

  1. 使用/导出 url

  2. 正在使用打印任务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);
    

那么,这两种方法有什么区别呢?

  1. 是 ArcGIS Server 提供的用于生成地图图像的 REST API。
  2. 是 ArcGIS JavaScript SDK 中的 Javascript 对象。

PrintTask 将使用来自 REST api 的 Export Web Map Task 生成地图图像。 PrintTask 提供了一种创建图像的简单方法。另一方面,如果您想直接使用 REST API,您可以使用 esri\request 对象,但是您必须生成 [=21= 描述的所有必需参数].

免责声明:我刚刚加入,没有评论的声誉;因此我必须 post 它作为对原始问题的回答,以下不是。

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

正如 T Kambi 所说,如果可用,使用 PrintTask 会更容易。在某些情况下,直接访问 Export Web Map Task REST 端点可能是有益的,例如:

  • Web_Map_as_JSON请求前需要修改参数 发送到导出 Web 地图任务地理处理服务。例如,需要添加地图中不存在的资源、需要更改图层的可见性、需要提供安全服务的令牌等。
  • 对于 JavaScript 环境,地图图像请求是从 ArcGIS API 外部发送的。可能没有实际的地图,人们只想使用 ArcGIS Server 功能来融合服务的图像并利用 Layout Template.

可以从客户端或服务器端访问导出 Web 地图任务。在后一种情况下,一种 "Print Task proxy" 可能有助于打印安全服务;例如,在使用 Long-lived Tokens.

的应用程序中消除对自定义打印服务的需求

现在回答原来的问题。

  1. Export Map REST 端点特定于 MapServer 服务,并允许为给定范围、指定图层、空间生成 服务 图像参考等

  2. 最终,PrintTask 向Export Web Map Task REST 端点发送请求。 Export Web Map Task 是用于生成 map 图像的接口,根据提供的 Web_Map_as_JSON 参数,可能存在多个服务和图形。它还提供了一个选项,可以使用预定义为 ArcGIS 模板(存储在服务器上)的布局包围地图图像。例如:

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

执行后,提供的结果中url的值为参考地图图片

Export Web Map Task interface results

注意:Web Map as JSON参数可以在API发送PrintTask请求后在浏览器的开发者工具中观察到。在这种情况下,它取自 ESRI 的 Print Dijit 示例: (不能 post 另一个 link)