[OpenLayers-Dev] Paper-print tiled maps in high-res

Ben Bucksch linux.news at bucksch.org
Fri Jun 29 16:11:06 PDT 2012


I need to print a map on paper, with layers. I created a separate HTML 
page for that. However, the OSM (OpenStreetMap) base layer prints with a 
screen resolution of 72dpi, which means: 1) most street names are not 
visible (and on paper, that's final, no zooming) 2) those streets names 
that are printed are often very pixelish, almost unreadable.

This is because browsers, at least Mozilla, always print with 72dpi, to 
make webpages look on paper then same as on screen. But it is possible 
to provide higher-resolution images: , with "img1000x1000px.png" having 
1000x1000px size, will give a high-res print in Mozilla.
This will print 1000 px on 3,55 cm on paper (100 pixels / 72 dots per 
inch * 2,56 cm/inch = 3,55 cm), i.e. result in 720 dpi (1000px/100px * 
72 dpi).
In other words, the image file must have 10 times the pixel size than 
the size in page per CSS width/height.

This means, we need to adapt the OSM -> XYZ -> Grid -> Layer class for 
that. The grid must be 10 times finer than it is for the screen.

Now, the question is: how to achieve this best, in Grid.js? Change 
tileSize? Change resolution? Both?

I've already changed the tileSize sucessfully. The map is loading with 8 
times more tiles in the same space, and Mozilla is printing that in high 
res, with 576 dpi. Patch attached.

However, the zoom level is still the same, so that the map is off, i.e. 
a larger globe area shown, not higher res of the same globe area. I 
think I need to change getResolution(), but I am not clear on what 
exactly resolution and zoom are and which exact function I need to modify.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tilelat-3.diff
Type: text/x-diff
Size: 4841 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20120630/4d64043c/attachment.diff>

More information about the Dev mailing list