I am new with the GeoServer printing module, in GeoServer version 2.6.0, freshly installed a few days ago.
I can now print WMS layers and I think I configured the OSM data correctly. But it still does not work for printing OSM, so I must have mistakes somewhere.
I am using OpenLayers and the default url for OSM seems to be "tile.openstreetmap.org"
I have set up the OSM url in the hosts section in the config.yaml file:
- !dnsMatch
host: tile.openstreetmap.org
My printing url is constructed as follows:
var url = 'http://xxx.xxx.x.xxx:8080/geoserver/pdf/print.pdf?spec=';
var options = {
units: 'm',
srs: 'EPSG:900913',
layout: 'A4 portrait',
dpi: '300',
mapTitle: 'This is the map title',
comment: 'This is the map comment',
layers: [
{
baseURL: 'http://tile.openstreetmap.org',
singleTile: false,
type: 'OSM',
maxExtent: [-20037508.3392,-20037508.3392,20037508.3392,20037508.3392],
tileSize: [256, 256],
extension: 'png',
resolutions: [156543.0339, 78271.51695, 39135.758475, 19567.8792375, 9783.93961875, 4891.969809375, 2445.9849046875, 1222.99245234375, 611.496226171875, 305.7481130859375, 152.87405654296876, 76.43702827148438, 38.21851413574219, 19.109257067871095, 9.554628533935547, 4.777314266967774, 2.388657133483887, 1.1943285667419434, 0.5971642833709717]
},
{
baseURL: 'http://xxx.xxx.x.xxx:8080/geoserver/abc/wms',
opacity: 1,
singleTile: true,
type: 'WMS',
layers: [layers],
format: 'image/jpeg'
}
],
pages: [
{
center: [center.lon, center.lat],
scale: map.getScale()
}
]
};
var printUrl = url + JSON.stringify(options);
As you can see below, the WMS layers are correctly printed, but the OSM layer does not appear, even though there was no error message during the printing.
Best Answer
Thank you for your answers.
I changed the base url to:
in the OSM configurations.
I also changed the host to
in the YAML file.
Also! I found out why it didn't work. It was a stupid mistake of mine.
I used JPEG format for the WMS layers that were over the OSM layer.
I only changed the format to PNG, to allow transparency in the WMS layers and I am now able to see the OSM layer.