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.
-
3See the PyQGIS Cookbook.– Germán CarrilloJul 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.– corvusJul 25, 2021 at 5:38
1 Answer
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.