[Qgis-developer] Re: Command to avoid one layer replacing last layer

Echavarria Gregory, Maria Angelica m.echavarriagregory at umiami.edu
Wed Nov 25 22:49:18 EST 2009


>Angelica,
>Try replacing:
>layers = [cl]
>self.canvas.setLayerSet(layers)
>With:
>layers = self.canvas.mapRenderer().layerSet()
>layers.insert(0,cl)
>self.canvas.setLayerSet(layers)

Aaron, thanks for your answer,

I tried the replacement you recommended and got a Type error (cl must be QStringList type), then I tried correcting the issue with the following in the vector layer method:

 cl= QgsMapCanvasLayer (layer)
layers = list (self.canvas.mapRenderer ( ).layerSet ( ) )
 layers.insert(0, cl)
self.canvas.setLayerSet(layers)

And I got no error message for the Vector layer method any more, but I did the same correction in the same part of the raster layer method and when using it, I'm getting that the argument in 
 self.canvas.setLayerSet(layers) has an invalid type. Could you please tell me what's wrong? I was thinking I may have to make "layers" a global variable and call it from my raster method to keep inserting in it... but it doesn't have the type I'd need to do so... I'm not quite understanding how this "appending" of layers works...     :-|

I need to upload the vector first because it is the base map, then add the raster, and then I do have to reorganize my layers as you said when I get the layerset ok, thank you.

Thanks a lot,
Angelica.


More information about the Qgis-developer mailing list