HSLayers.Printer

HSLayers.Printer is another Ext.Panel with special functionality. When the panel is activated, it will draw paper on the map. You can set several options and let the map be printed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
        <script type="text/javascript" src="../source/HSLayers/Printer.js"></script>

        <script type="text/javascript">
            OpenLayers.ProxyHost = "/cgi-bin/olproxy.cgi?url=";
            HSLayers.Printer.printerScript = "http://portal.plan4all.eu/cgi-bin/mapCreator.py";

            // create the map panel
            printerPanel = new HSLayers.Printer({
                renderTo: Ext.get("printer")
            });

            printerPanel.setMap(map)
        </script>

Note

Two attributes have been set: OpenLayers.ProxyHosty which points OpenLayers (and HSLayers) to server-side ajax proxy script, and HSLayers.Printer.printerScript, which should point the printing client to hslayers/source/scripts/mapCreator.py server printing script.

We also created two Ext.Buttons which do activate and deactivate the panel functionality.

1
2
3
4
5
6
7
8
9
            var activateButton = new Ext.Button({
                    text:"Activate",
                    handler: function(){printerPanel.fireEvent("activate")}, 
                    renderTo: Ext.get("buttons")});

            var deActivateButton = new Ext.Button({
                    text:"Deactivate",
                    handler: function(){printerPanel.fireEvent("deactivate")}, 
                    renderTo: Ext.get("buttons")});

mapCreator.py

This script, located in hslayers/source/scripts/mapCreator.py is server-side printing script. It accepts JSON object describing the content of the map, and makes PDF out of it.

The script is written in Python and uses python-pyx module for the PDF formating.

The map is expected to be array of URLs to images together with their bounding boxes. So it is able to print WMS layers, TileCache files, single image layers and so on, tiled or single-file. It is able to set opacity of each layer as well.

It is able to print legends to each layer on separate paper.

Currently, vectors are not supported. The map must not use WGS84 coordinate reference system.

Table Of Contents

Previous topic

HSLayers.OWS

Next topic

HSLayers.MapViewer

This Page