[Qgis-developer] Adding a WMS layer in QGIS 2.0 (python)
Enzo Ciarmoli
enzo.ciarmoli at csi.it
Wed Oct 2 09:10:01 PDT 2013
>From: Luca Manganelli <luca76 at gmail.com>
>To: qgis-developer <qgis-developer at lists.osgeo.org>
>Subject: [Qgis-developer] Adding a WMS layer in QGIS 2.0 (python)
>
>Hi,
>the QgsRasterLayer costructor has changed. If I try this:
>
>rlayer =
>QgsRasterLayer('http://testsrv/mapaccel?map=ciao.map&crs=EPSG:25832&format=image/png',
>'test', 'wms')
>QgsMapLayerRegistry.instance().addMapLayer(rlayer)
>self.iface.mapCanvas().refresh()
>
>the wms raster layer is never added to map. How can I fix this?
QgsRasterLayer constructor has changed, now it accept four arguments, the first
is the uri string.
To construct the uri string you must know what layers you want.
You could try this:
desired_layer = 'abcdefg'
uri = 'crs=EPSG:25832&featureCount=10&format=image/png&layers=' + desired_layer
+ '&styles=&url=http://testsrv/mapaccel?map=ciao.map'
rlayer = self.iface.addRasterLayer(uri, 'test', 'wms')
Hope this helps!
Enzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131002/2bbde747/attachment.html>
More information about the Qgis-developer
mailing list