[Qgis-developer] QgsComposerMap zoomToExtent problem

James Stott jamesstott1 at gmail.com
Sun Nov 22 11:23:53 PST 2015


Hi,

I have a QgsComposerMap that I want to zoom to the extent of a feature in a
vector layer.

geomBBRect = geometry.boundingBox()
myComposerMap.zoomToExtent(geomBBRect)

I am trying to use zoomToExtent to make the map show the correct area.
However, I get a blank map when I run my code. If I check what the current
scale is, its returned as 'nan'.

I tried using setNewExtent() before, but this alters the size of my
QgsComposerMap. I want to keep the same map size each time.

After doing a little bit of checking, it seems that:

myComposerMap.currentMapExtent().xMinimum()))
myComposerMap.currentMapExtent().xMaximum()))

both return 'nan' but yMinimum and yMaximum return coordinates.

I can not figure out why. Can anyone help shed any light on the problem? I
can provide more code if needed.

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151122/0364ec41/attachment.html>


More information about the Qgis-developer mailing list