[Qgis-user] Fwd: Re: Web client background layer printing

Bernhard Ströbl bernhard.stroebl at jena.de
Thu May 22 05:29:56 PDT 2014


Hi,

this is the drawback of background layers. They are not layers in the
project.
What I do:
I load the same layers (given they are WMS layers) additionally into the
project (with the same name!) Thus these layers can be printed. To
ensure they are visible when the user clicks on printing I use the
following code (in Customizations.js, ATTENTION: work in progress):

// this is a default function in Customizations.js
function customBeforePrint() {
     var myCheckedBackgroundLayer = "";
     layerTree.root.lastChild.cascade(
         function (n) {
             if (n.isLeaf() && n.attributes.checked) {
                 myCheckedBackgroundLayer = n.text;
             }
         }
     );

     if (myCheckedBackgroundLayer != "") {
         toggleThematicBackgroundLayer(myCheckedBackgroundLayer, true);
     }
}

// this is an additional function I added to Customizations.js
// It scans through the layer tree and as soon as it hits a layer with
// the same name as the currently visible background layer it adds it to
// the visible layers
function toggleThematicBackgroundLayer(layerName, show) {
     layerTree.root.firstChild.cascade(
         function (n) {
             if (n.isLeaf() && n.text == layerName) {
                 n.getUI().toggleCheck(show);
             }
         }
     );
     var myLayers = thematicLayer.params.LAYERS;

     if (show) {
         myLayers = layerName + "," + myLayers ;
     } else {
         myLayers.replace(layerName + ",", "");
     }
     thematicLayer.params.LAYERS = myLayers;
}


good luck

Bernhard



Am 22.05.2014 14:17, schrieb Uggla Henrik:
> Is it somehow possible to print a web client map with its background layer visible on the print?
>
> cheers
> Henrik
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
> __________ Information from ESET Mail Security, version of virus signature database 9834 (20140522) __________
>
> The message was checked by ESET Mail Security.
> http://www.eset.com
>
>





__________ Information from ESET Mail Security, version of virus signature database 9834 (20140522) __________

The message was checked by ESET Mail Security.
http://www.eset.com





More information about the Qgis-user mailing list