0

I'd like to use PyQGIS to open a new map view with its own map canvas & coordinate system. This seems like a very basic questions but I can't find any information about it! I suppose I can somehow embed a new MapCanvas instance inside a QWidget, but I am not sure how to do this.

2
  • 3
    See the PyQGIS Cookbook. Jul 25, 2021 at 1:40
  • @GermánCarrillo Thank you. I had looked at the cookbook already but apparently I had not understood it as the task was far easier than I realized.
    – corvus
    Jul 25, 2021 at 5:38

1 Answer 1

3
map=QgsMapCanvas()
map.show()

Afterwards handle the events and use methods like, map.setExtent() map.setLayers([layer]).

If you are doing it in QT Designer make a Widget and promote it to QgsMapCanvas. Rest Pyuic5.bat will take care.

Not the answer you're looking for? Browse other questions tagged or ask your own question.