<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head><body style="">
<div>
>From: Luca Manganelli <luca76@gmail.com>
</div>
<div id="ox-signature">
<p style="margin: 0;">>To: qgis-developer <qgis-developer@lists.osgeo.org><br/>>Subject: [Qgis-developer] Adding a WMS layer in QGIS 2.0 (python)<br/>><br/>>Hi,<br/>>the QgsRasterLayer costructor has changed. If I try this:<br/>><br/>>rlayer = QgsRasterLayer('http://testsrv/mapaccel?map=ciao.map&crs=EPSG:25832&format=image/png', 'test', 'wms')<br/>>QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br/>>self.iface.mapCanvas().refresh()<br/>><br/>>the wms raster layer is never added to map. How can I fix this?<br/><br/>QgsRasterLayer constructor has changed, now it accept four arguments, the first is the uri string.</p>
<p style="margin: 0;">To construct the uri string you must know what layers you want.</p>
<br style="margin: 0;"/>
<p style="margin: 0;">You could try this: <br/><br/>desired_layer = 'abcdefg'<br/>uri = 'crs=EPSG:25832&featureCount=10&format=image/png&layers=' + desired_layer + '&styles=&url=http://testsrv/mapaccel?map=ciao.map'<br/>rlayer = self.iface.addRasterLayer(uri, 'test', 'wms')</p>
<p style="margin: 0;"> </p>
<p style="margin: 0;">Hope this helps!</p>
<p style="margin: 0;"> </p>
<p style="margin: 0;">Enzo</p>
<p style="margin: 0;"> </p>
<p style="margin: 0;"> </p>
</div>
</body></html>