I have a stand-alone PyQGIS application that can load vectors/rasters etc. The problem I am facing is when the application is launched, it has an empty QgsMapCanvas as map display, when it is empty, I mean has no layer features on the canvas, the canvas appears to have empty extent. If I do the following:

canvas.extent().isEmpty() (this is true)
canvas.extent().width() (this is 0.0)
canvas.extent().height() (this is 0.0)

At this point, if I put a point on the canvas, and call canvas.zoomToFullExtent(), then the canvasMoveEvent will stop working (stop capturing mouse move's coordinates)

So, my plan is to get the canvas's visible center and manually set its extent to the visible view port that is displayed in the application when it is first launched. But I couldn't find a way to do that or even if this is possible. Basically, something like canvas.extent().center() or something...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.