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

2014-05-22 Thread Luca Manganelli
On Thu, May 22, 2014 at 2:29 PM, Bernhard Ströbl
 wrote:
> 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):

Marvellous! But are they (the WMS background layers) visible in the
layerTree, too?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-05-22 Thread Bernhard Ströbl

Hi Luca,

of course theses layers are now twice in the layer tree. Once in the 
upper leaf derived from the qgs file and once in the lower "Background 
Layers" leaf. For user interaction I did some more scripting:
If the user toggles visibility of the layer in the upper leaf this 
toggling is ignored and the corresponding layer is toggled in the lower 
leaf.


Bernhard

Am 22.05.2014 14:48, schrieb Luca Manganelli:

On Thu, May 22, 2014 at 2:29 PM, Bernhard Ströbl
 wrote:

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):


Marvellous! But are they (the WMS background layers) visible in the
layerTree, too?


__ 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


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-05-22 Thread Bernhard Ströbl

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@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


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user