Openlayers 3 以OSM为背景层的OL3和geoserver打印模块

Openlayers 3 以OSM为背景层的OL3和geoserver打印模块,openlayers-3,geoserver,Openlayers 3,Geoserver,我有一个内置于OL3和geoserver中的应用程序。我在应用程序中使用引导和jQuery 我正在尝试以pdf格式打印地图。我将OSM作为我的应用程序的基础层,其他层来自我的本地geoserver 现在我有一个情况,我需要打印pdf格式的地图(所有可见层和OSM层) 我已经在我的geoserver中安装了打印插件,它工作正常。我已经用以下代码测试了我的打印模块: http://localhost:8080/geoserver/pdf/print.pdf?spec={ "layout":"

我有一个内置于OL3和geoserver中的应用程序。我在应用程序中使用引导和jQuery

我正在尝试以pdf格式打印地图。我将OSM作为我的应用程序的基础层,其他层来自我的本地geoserver

现在我有一个情况,我需要打印pdf格式的地图(所有可见层和OSM层)

我已经在我的geoserver中安装了打印插件,它工作正常。我已经用以下代码测试了我的打印模块:

http://localhost:8080/geoserver/pdf/print.pdf?spec={
    "layout":"A4 portrait",
    "srs":"EPSG:4326",
    "units":"degrees",
    "dpi":300,
    "outputFilename": "map",
    "mapTitle":"This is the map title",
    "layers":[
    {
        "baseURL":"http://localhost:8080/geoserver/genesis/wms",
        "opacity":0.5,
        "singleTile":false,
        "type":"WMS",
        "layers":["District_Boundary", "DevelopmentRegions"],
        "format":"image/png",
        "styles":[]
    } 
    ],
    "pages":[
    {
        "center":[84.25,28.1],
        "mapTitle":"",
        "comment":"",
        "scale":4000000,
        "rotation":0
    }
    ] }
但问题是,我应该如何在这里打印我的OSM层??我没有在我的应用程序中使用Extjs,所以我不想仅仅为了打印功能而使用它

有人能建议我如何使用jQuery和引导以及没有Extjs的纯javascript吗


谢谢。

Geoserver打印插件仅适用于Geoserver数据。在您的情况下,应该将OSM数据作为geoserver实例中的一个层来处理。不可能仅通过geoserver“代理”OSM磁贴,您必须将OSM数据导入数据库。请检查这篇文章:

当你使用OL3(画布支持)时,可以考虑浏览器侧打印。从画布获取图像非常简单:

您还可以使用以下方式在JavaScript中生成PDF:

您只需将osm作为另一层添加到您的请求负载中,如下所示

http://localhost:8080/geoserver/pdf/print.pdf?spec={
    "layout":"A4 portrait",
    "srs":"EPSG:4326",
    "units":"degrees",
    "dpi":300,
    "outputFilename": "map",
    "mapTitle":"This is the map title",
    "layers":[
       {  
         "baseURL":"http://a.tile.openstreetmap.org",
         "maxExtent":[  
            //your extent of map in the correct projection
         ],
         "tileSize":[  
            256,
            256
         ],
         "extension":"png",
         "type":"OSM",
         "opacity":1
      },{
        "baseURL":"http://localhost:8080/geoserver/genesis/wms",
        "opacity":0.5,
        "singleTile":false,
        "type":"WMS",
        "layers":["District_Boundary", "DevelopmentRegions"],
        "format":"image/png",
        "styles":[]
    }
    ],
    "pages":[
    {
        "center":[84.25,28.1],
        "mapTitle":"",
        "comment":"",
        "scale":4000000,
        "rotation":0
    }
    ] }
您需要根据需要更改范围

发送请求后,Geoserver将填充osm磁贴并将其放在地图上


请注意,您应该将osm层放在json字符串中其他层之前,否则它将被放在打印地图中其他层的顶部。

还没有??有人知道怎么做吗?没有进展或解决方案,我的朋友??没有人遇到过这个问题??