> From: nyall.daw...@gmail.com
> Subject: [Qgis-developer] Adding a WMS layer via python
> I'm wondering if someone can help me out here - I'm trying to add a
> WMS layer via a python plugin, but I'm having trouble with two
> settings I need:
> 
> 1: setting a username and password to use for the layer
> 2: setting a tilesize for the layer
>> One thing I've noticed is that the uri.encodedUri output looks strange:
> 
> crs=EPSG:3111&format=image/jpeg&height=512&layers=AERIAL_MELBOURNE_2009JAN03_AIR_VIS_35CM_VG94&styles=&url=http://images.land.vic.gov.au/ecwp/ecw_wms.dll?&width=512
> 
> Any ideas what I'm doing wrong on this one?

Hi Nyall,
I haven't had need to tweak the tile size so I can't offer any advice 
there.However I have had success adding authenticated WMS layers to 1.8 with 
this code:
if len(self.user) > 0 : connectionString = "username=" + self.user + 
",password=" + self.password + ",url=" + self.urlelse:     connectionString = 
self.url
crs = self.iface.mapCanvas().mapRenderer().destinationCrs().authid()
layer = QgsRasterLayer(0, connectionString, self.title, "wms",[self.layername], 
["default"], "image/png", crs)
if layer.isValid():     QgsMapLayerRegistry.instance().addMapLayer(layer)
This code manually adds the username, and password parameters to the connection 
string, you may want to try something similar with your URI.
Regards,Kelly Thomas                                      
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to