[Qgis-developer] addMapLayer and position in the stack
motta.luiz at gmail.com
motta.luiz at gmail.com
Mon Nov 23 05:13:29 EST 2009
Michele,
You need define QgsMapCanvasLayer, after use QgsMapCanvas::setLayerSet
with list of layers.
I make this for in my plugin "Image show or hide" (user-contributed in
"http://www.pyqgis.org/" )
Obs: when change the order layer set (QgsMapCanvas::setLayerSet) the
legend continue with old oder.
The code below add layer (Raster Layer, use for setNoDataValue) in
bottom stack (copied by plugin)
def __getListCanvasLayer(self):
# Return : List of QgsMapCanvasLayer with change visible toggle layer
# dicLyrs -> Key = LayerId , Value = Layer
dicLyrs = core.QgsMapLayerRegistry.instance().mapLayers()
# List of layers in legend
lstLyrIdLegend = self.__mapCanvas.mapRenderer().layerSet()
lstReturn = []
for lyrId, lyr in dicLyrs.iteritems():
isVisible = True
if lstLyrIdLegend.indexOf(lyrId) == -1:
isVisible = False
lstReturn.append(gui.QgsMapCanvasLayer(lyr, isVisible))
return lstReturn
def __addImgLastPosition(self, lyr):
lyr.setNoDataValue(0)
lstMapCanLyr = self.__getListCanvasLayer()
core.QgsMapLayerRegistry.instance().addMapLayer(lyr);
lstMapCanLyr.append(gui.QgsMapCanvasLayer(lyr, True))
self.__mapCanvas.setLayerSet(lstMapCanLyr)
Best Regards,
Luiz Motta
Michele Mammini escreveu:
> Dear All,
>
> when you add a layer with the command addMapLayer, this layer is
> loaded at the top of the stack.
> is it possible to set the position of the layer we want to load?
> is it possible to load it at the bottom of the stack?
>
> Do someone know how to solve it?
>
> Thank you Michele.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
More information about the Qgis-developer
mailing list