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

Tim Sutton lists at linfiniti.com
Wed Sep 19 12:41:08 PDT 2012


Hi
On Sep 19, 2012 5:33 PM, "DanielK" <daniel.klich at gmx.de> wrote:
>
> 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 ?
>

Correct.

Regards

Tim

> 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.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120919/3ddd898e/attachment.html>


More information about the Qgis-developer mailing list