[Qgis-developer] plugin zoom question

Denis Rouzaud denis.rouzaud at gmail.com
Wed Apr 25 01:00:56 EDT 2012


Hi,

How is defined self.plugin ?

On 04/25/2012 01:30 AM, SJWC GIS wrote:
> Hello all,
>
> I've written a piece of code that will search a database for a given 
> point, and then return that point so we can center the map canvas on 
> it and zoom in.  Unfortunately, it's not working.  QGIS crashes after 
> the code executes, leaving no error messages behind.  Is there a 
> better way to center/zoom to a given point?  I've tried the canvas 
> method "centerWithZoom" as well, with no success.  (It also crashes.) 
>  I have checked my coords -- they are in the proper projection (the 
> same as the mapCanvas) and I haven't reversed them.  Any other 
> ideas/methods of accomplishing this are greatly appreciated.  Thanks!
>
> Aaron
>
>       x = result[0][1]
>       y = result[0][2]
>       xscale = 1.0
>
>       # Get the map canvas
>       mc = self.plugin.iface.mapCanvas()
>
>       height2 = mc.extent().height() * xscale / 2.0
>       width2 = mc.extent().width() * xscale / 2.0
>
>       rect = QgsRectangle(x-width2,y-height2,x+width2,y+height2)
>
>       # Set the extent to our new rectangle
>       mc.setExtent(rect)
>
>       # Refresh the map
>       mc.refresh()
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120425/ace427e4/attachment.html


More information about the Qgis-developer mailing list