首页 / 浏览问题 / WebGIS / 问题详情
前端怎么调用打印服务,为什么参考示例,怎么调用都不对?
hyh
2EXP 2022年11月10日

前端怎么调用打印服务,为什么参考示例,怎么调用都不对?
这是上传的参数:
 

{
    "layoutOptions": {
        "id": "A4_landscape",
        "template": "A4 landscape",
        "title": "主标题",
        "subTitle": "副标题",
        "author": "作者",
        "copyright": "版权信息",
        "legendOptions": {
            "title": "图例",
            "customItems": [
                {
                    "name": "011",
                    "picAsUrl": [
                        "http://172.180.0.10:8090/iserver/output/resources/dltb2010/SYMBOLFILL/100_-137274601.png"
                    ]
                }
            ]
        }
    },
    "exportOptions": {
        "format": "pdf",
        "dpi": 120
    },
    "content": {
        "type": "WEBMAP",
        "value": {
            "extent": {
                "leftBottom": {
                    "x": 112.20922091037036,
                    "y": 32.01429961258589
                },
                "rightTop": {
                    "x": 112.21894719069073,
                    "y": 32.02402589290625
                }
            },
            "maxScale": "1:144447.927",
            "level": 4,
            "center": {
                "x": 112.21408405053054,
                "y": 32.01916275274607
            },
            "baseLayer": {
                "layerType": "TILE",
                "name": "dltb2010",
                "url": "http://172.180.0.10:8090/iserver/services/map-dltb2010/rest/maps/dltb2010"
            },
   
            "description": "",
            "projection": "GCS_China_2000",
            "minScale": "1:591658710.909",
            "title": "testdizhen",
            "version": "2.2.1",
            "rootUrl": "http://172.180.0.10:8090/iserver/services"
        }
    }
}

结果:

1个回答

您好,您可以参考帮助文档:http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iServer/mergedProjects/SuperMapiServerRESTAPI/root/webprinting/webPrintingJobs.htm进行参数设置,我这边用以下请求参数请求成功,如果您有map-china400这个示例服务,可以尝试直接用文档参数打印测试,

{

    "layoutOptions": {

        "templateName": "A4_landscape",

        "title": "主标题",

        "subTitle": "副标题",

        "author": "作者",

        "copyright": "版权信息",

        "northArrowOptions": {

        },

        "scaleBarOptions": {

            "scaleText": "比例尺"

        },

        "legendOptions": {

            "title": "图例",

            "customItems": [

                {

                    "name": "重要设置",


                },

                {

                    "name": "河流",

                    "picAsUrl": 

                        "http://localhost:8090/iserver/services/map-china400/rest/maps/China/layers/River@China@@China/legend"

                    

                },

                {

                    "name": "主干道",

                    "picAsUrl": 

                        "http://localhost:8090/iserver/services/map-china400/rest/maps/China/layers/Main_Road_L@China@@China/legend"

                    

                }

            ]

        },

        "littleMapOptions": {

            "center": {

                "x": 12659780.84769,

                "y": 1630935.5331

            },

            "scale": 2.63157894736842E-08,

            "layers": [

                {

                    "layerType": "TILE",

                    "name": "China",

                    "url": "http://localhost:8090/iserver/services/map-china400/rest/maps/China"

                }

            ]

        }

    },

    "exportOptions": {

        "format": "pdf",

        "dpi": 96

    },

    "content": {

        "type": "WEBMAP",

        "value": {

            "maxScale": "1:144447.927",

            "level": 4,

            "center": {

                "x": 12024583.8595938,

                "y": 4101942.08146721

            },

            "layers": [

                {

                    "layerType": "TILE",

                    "name": "China",

                    "url": "http://localhost:8090/iserver/services/map-china400/rest/maps/China"

                }

            ],

            "description": "",

            "projection": "EPSG:3857",

            "minScale": "1:591658710.909",

            "title": "china_point",

            "version": "2.0.0"

        }

    }

}

您对照检查一下各个参数设置,比如您的"projection",应该使用"EPSG:3857"的格式,否则无法打印成功,其他参数您需要自行检查。

3,148EXP 2022年11月10日
...