准备打印内容

发送反馈


SuperMap iServer Web 打印服务支持打印的 Web 内容为 WebMap,即:在线创建的地图。您在使用 iServer Web 打印服务创建打印任务时,输入的请求体中需提供 WebMap 的 “JavaScript 对象标记法”(JSON)表达。此 JSON 必须根据SuperMap WebMap 规范构建。

使用 SuperMap iPortal 的数据上图 Web App 制作的 WebMap,无需为构建 JSON 担心,您只需在请求体的 content 对象中的 url 参数中,传递一个 SuperMap iPortal WebMap 的 url 地址,例如:

{

    "content": {

        "type": "WEBMAP",

        "url":"http://supermapiportal:8190/iportal/web/maps/{mapid}/map.rjson"

     },

    "layoutOptions": {

           ......

     },

    "exportOptions": {

          ......

     }

}

您也可以在请求体的 content 对象中的 value 对象中传递一个完整的 SuperMap iPortal 数据上图制作的 WebMap 的 json 表达,例如:

{

    "content": {

        "type": "WEBMAP",

        "value": {

            "extent": {

                "leftBottom": {

                    "x": -20037508.3427892,

                    "y": -20037508.3427891

                },

                "rightTop": {

                    "x": 20037508.3427892,

                    "y": 20037508.3427891

                }

            },

            "maxScale": "1:144447.927",

            "level": 4,

            "center": {

                "x": 11382417.9336122,

                "y": 4134167.44525748

            },

            "baseLayer": {

                "layerType": "TILE",

                "name": "ChinaDark",

                "url": "https://iserver.supermap.io/iserver/services/map-china400/rest/maps/ChinaDark"

            },

            "layers": [

                {

                    "layerType": "VECTOR",

                    "visible": true,

                    "name": "中国历史6级以上地震记录",

                    "featureType": "POINT",

                    "xyField": {

                        "xField": "经度",

                        "yField": "纬度"

                    },

                    "style": {

                        "fillColor": "#EE4D5A",

                        "strokeWidth": 1,

                        "offsetX": 0,

                        "offsetY": 0,

                        "fillOpacity": 0.9,

                        "radius": 8,

                        "strokeColor": "#ffffff",

                        "type": "BASIC_POINT",

                        "strokeOpacity": 1

                    },

                    "projection": "EPSG:4326",

                    "enableFields": [

                        "年",

                        "月",

                        "日",

                        "时",

                        "分",

                        "秒",

                        "经度",

                        "纬度",

                        "深度",

                        "震级",

                        "震级类型",

                        "参考地名"

                    ],

                    "dataSource": {

                        "name": "ChinaRecordOfOver6Earthquakes",

                        "type": "SAMPLE_DATA"

                    }

                }

            ],

            "description": "",

            "projection": "EPSG:3857",

            "minScale": "1:591658710.909",

            "title": "testdizhen",

            "version": "2.2.1",

            "rootUrl": "https://iptl.supermap.io/iportal/services/../"

        }

    },

    "layoutOptions": {

           ......

     },

    "exportOptions": {

          ......

     }

}

目前, Web 打印服务支持的 WebMap 图层包括:矢量图层、天地图、WMS、WMTS、iServer REST 地图服务及临时图层、单值专题图、分段专题图、等级符号专题图、标注图层,对应 SuperMap WebMap 规范中的图层分别是:VectorLayer、TiandituLayer、WMSLayer、WMTSLayer、TileLayer、UniqueLayer、RangeLayer、RankSymbolLayer、MarkerLayer、MapStylerLayer。

注意:针对天地图服务,Web 打印服务还支持打印以 WMTS 形式加载的天地图,请求体的构建可参考 WMTSLayer,需要注意的是,如果您加载的天地图是 EPSG:3857坐标系,需要在 WMTS 图层的请求体中额外增加一个矩阵数组参数:matrices,具体请求示例如下:

{

    "layers": [

        {

            "layerType": "WMTS",

            "name": "vec",

            "visible": true,

            "url": "http://t0.tianditu.gov.cn/vec_w/wmts?tk=67942a36e0dd97aa9d72f42393454241",

            "tileMatrixSet": "w",

            "matrices": [

                {

                    "identifier": "1",

                    "matrixSize": [

                        2,

                        2

                    ],

                    "scaleDenominator": 279541131.975446,

                    "tileSize": [

                        256,

                        256

                    ],

                    "topLeftCorner": [

                        -20037508.34,

                        20037508

                    ]

                }

            ],

            "layer": "vec",

            "requestEncoding": "KVP",

            "opacity": 1,

            "style": "default",

            "imageFormat": "tiles"

        }

    ]

}