<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
How is defined self.plugin ?<br>
<br>
On 04/25/2012 01:30 AM, SJWC GIS wrote:
<blockquote
cite="mid:CAEP=zx_pu=BJm-+-Zv9JuSRwm7vdUKpPgvOXqKS1ythFULmq+w@mail.gmail.com"
type="cite">Hello all,
<div><br>
</div>
<div>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!</div>
<div><br>
</div>
<div>Aaron</div>
<div><br>
</div>
<div>
<div> x = result[0][1]</div>
<div> y = result[0][2]</div>
<div> xscale = 1.0</div>
<div><br>
</div>
<div> # Get the map canvas</div>
<div> mc = self.plugin.iface.mapCanvas()</div>
<div><br>
</div>
<div> height2 = mc.extent().height() * xscale / 2.0</div>
<div> width2 = mc.extent().width() * xscale / 2.0</div>
<div><br>
</div>
<div> rect =
QgsRectangle(x-width2,y-height2,x+width2,y+height2)</div>
<div><br>
</div>
<div> # Set the extent to our new rectangle</div>
<div> mc.setExtent(rect)</div>
<div><br>
</div>
<div> # Refresh the map</div>
<div> mc.refresh()</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
</body>
</html>