1

I have a small plugin for QGis which is collecting paratemters from gui for URL request to load raster layes (WMS).

Example:

 urlWithParams = self.get_values()
 mylayer = QgsRasterLayer(urlWithParams, (self.dockwidget.txt_layer_name.text()), "wms")
 QgsMapLayerRegistry.instance().addMapLayer(mylayer, False)
 self.root.insertLayer(0, mylayer)

Everything is working fine, but the unexpected behavior of QGis appears, if I have a vector layer loaded and then I load the raster layer, the zoom in shifts to the magnifier, then I have to lock and unlock the scale to work with scale.

Why it switch to magnifier and if there is a way through the python script to 'force' to work with the scale instead of the magnifier after loading the raster layer?

enter image description here

Its happening something like that wheel action is conected to the magnifier instead of scale after loading raster layer, how to connect wheel action with scale?

1

if someone is going to have the same problem, in the end the solution was very simple:

self.iface.mapCanvas().setScaleLocked(False)    

setScaleLocked

void QgsMapCanvas::setScaleLocked (bool isLocked) 

Lock the scale (set True), so zooming can be performed using magnication, or oposite set False so zooming can be performed using scale.

Since QGIS 2.16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.