<div dir="ltr"><div><div><div><div>I'm trying to solve a problem involving a change to QGIS handling of the setSubLayerVisibility method for a WMS layer.  I've noticed the difference between versions 2.0 and 2.6, but I don't know when it was introduced because I don't have the other versions installed.<br><br></div>The code below will create a WMS layer from the UK National Biodiversity Network (NBN). (The code starting 'NHM...' specifies that this is a UK species distribution map for the Robin.)<br><br></div>The WMS layer is created with four sub-layers. The code below turns off visibility for three of the sub-layers, leaving only one visible. (In the plugin I change the sub-layer visibility depending on the extent of the map.)<br><br></div>If I run the sample code in QGIS 2.0, I see only the "Grid-2km" sub-layer. But if I run it in QGIS 2.6, I see all four sub-layers - the setSublayerVisibility method has no effect.<br><br></div>Can anyone confirm whether or not this is a bug, of if there has been a change to handling sub-layer visibility that I should be aware of?<br><div><div><div><div><div><div><br>         url = ("url=<a href="https://gis.nbn.org.uk/SingleSpecies/NHMSYS0000530739&">https://gis.nbn.org.uk/SingleSpecies/NHMSYS0000530739&</a>" +<br>        "layers=Grid-100m&layers=Grid-1km&layers=Grid-2km&layers=Grid-10km" +<br>        "&styles=&styles=&styles=&styles=" +<br>        "&format=image/png&crs=EPSG:27700")<br>        <br>        rlayer = QgsRasterLayer(url, 'NBN WMS layer', 'wms')<br>        QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br>        <br>        rlayer.setSubLayerVisibility("Grid-10km", False)<br>        rlayer.setSubLayerVisibility("Grid-2km", True)<br>        rlayer.setSubLayerVisibility("Grid-1km", False)<br>        rlayer.setSubLayerVisibility("Grid-100m", False)<br></div></div></div></div></div></div></div>