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>