[Qgis-developer] Display raster layer on own Map Canvas

DanielK daniel.klich at gmx.de
Wed Sep 19 08:33:11 PDT 2012


Tim Sutton-4 wrote
>> I load a raster layer, set canvas color and so on. But the layer only
>> displays if i use QgsMapLayerRegistry.instance().addMapLayer(self.layer).
>> Without these code line my plugin only displays the rubber band, but not
>> the
>> raster layer. But if i use ...addMapLayer() it also loads the layer in
>> QGIS.
>> I want to have a behaviour like in the GDAL - Georeferenzierung plugin.
>> There you could add a raster layer and the plugin displays it only in the
>> plugin window, not in the QGIS MainWindow.
>>
> 
> Try passing False to QgsMapLayerRegistry.instance().addMapLayer(
> <layer>
> , [bool])
> 
> The bool options should suppress it being added to the main canvas.
> 
> Then manually add it to the map canvas by wrapping it as a
> mapcanvaslayer and explicitly passing a set of mapcanvaslayers using
> QgsMapCanvas.setLayerSet()

Thank you. That worked for me. (
QgsMapLayerRegistry.instance().addMapLayer(self.layer, False) )


Tim Sutton-4 wrote
> PS QgsMapLayerRegistry.instance().addMapLayer(
> <layer>
> , [bool]) is
> deprecated, use addMapLayers(
> <list>
> , bool) rather.

I am using Version 1.7.4. addMapLayers(<list>, bool) only works in 1.8.,
right ?

best regards,

Daniel




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Display-raster-layer-on-own-Map-Canvas-tp5002935p5002986.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list