QgsQuickMapSettings class
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of map rendering via QML properties.
Contents
On top of QgsMapSettings functionality, when QgsProject is attached, it automatically loads its default settings from the project. QgsProject should be attached before it is read.
Constructors, destructors, conversion operators
- QgsQuickMapSettings(QObject* parent = nullptr)
- Create new map settings.
Public functions
- auto coordinateToScreen(const QgsPoint& point) const -> Q_INVOKABLE QPointF
- Convert a map coordinate to screen pixel coordinates.
- auto destinationCrs() const -> QgsCoordinateReferenceSystem
- returns CRS of destination coordinate reference system
- auto extent() const -> QgsRectangle
- Returns geographical coordinates of the rectangle that should be rendered.
- auto layers() const -> QList<QgsMapLayer*>
- Gets list of layers for map rendering The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
- auto mapSettings() const -> QgsMapSettings
- Clone map settings.
- auto mapUnitsPerPixel() const -> double
- Returns the distance in geographical coordinates that equals to one pixel in the map.
- auto outputDpi() const -> double
- Returns DPI used for conversion between real world units (e.g.
- auto outputSize() const -> QSize
- Returns the size of the resulting map image.
- auto project() const -> QgsProject*
- A project property should be used as a primary source of project all other components in the application.
- auto rotation() const -> double
- The rotation of the resulting map image, in degrees clockwise.
- auto screenToCoordinate(const QPointF& point) const -> Q_INVOKABLE QgsPoint
- Convert a screen coordinate to a map coordinate.
- auto setCenter(const QgsPoint& center) -> Q_INVOKABLE void
- Move current map extent to have center point defined by center.
- void setDestinationCrs(const QgsCoordinateReferenceSystem& destinationCrs)
- sets destination coordinate reference system
- void setExtent(const QgsRectangle& extent)
- Set coordinates of the rectangle which should be rendered.
- void setLayers(const QList<QgsMapLayer*>& layers)
- Set list of layers for map rendering.
- void setOutputDpi(double outputDpi)
- Sets DPI used for conversion between real world units (e.g. mm) and pixels.
- void setOutputSize(const QSize& outputSize)
- Sets the size of the resulting map image.
- void setProject(QgsProject* project)
- A project property should be used as a primary source of project all other components in the application.
- void setRotation(double rotation)
- The rotation of the resulting map image, in degrees clockwise.
- void setTransformContext(const QgsCoordinateTransformContext& context)
- Sets the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
- auto transformContext() const -> Q_INVOKABLE QgsCoordinateTransformContext
- Returns the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
- auto visibleExtent() const -> QgsRectangle
- Returns the actual extent derived from requested extent that takes takes output image size into account.
Signals
- void destinationCrsChanged()
- CRS of destination coordinate reference system.
- void extentChanged()
- Geographical coordinates of the rectangle that should be rendered.
- void layersChanged()
- Set list of layers for map rendering.
- void mapUnitsPerPixelChanged()
- Returns the distance in geographical coordinates that equals to one pixel in the map.
- void outputDpiChanged()
- Output DPI used for conversion between real world units (e.g.
- void outputSizeChanged()
- The size of the resulting map image.
- void projectChanged()
- A project property should be used as a primary source of project all other components in the application.
- void rotationChanged()
- The rotation of the resulting map image, in degrees clockwise.
- void visibleExtentChanged()
- Returns the actual extent derived from requested extent that takes takes output image size into account.
Function documentation
Q_INVOKABLE QPointF QgsQuickMapSettings:: coordinateToScreen(const QgsPoint& point) const
Convert a map coordinate to screen pixel coordinates.
| Parameters | |
|---|---|
| point | A coordinate in map coordinates |
| Returns | A coordinate in pixel / screen space |
QgsRectangle QgsQuickMapSettings:: extent() const
Returns geographical coordinates of the rectangle that should be rendered.
The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use visibleExtent() to get the resulting extent.
double QgsQuickMapSettings:: outputDpi() const
Returns DPI used for conversion between real world units (e.g.
mm) and pixels Default value is 96
QgsProject* QgsQuickMapSettings:: project() const
A project property should be used as a primary source of project all other components in the application.
QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::
When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.
double QgsQuickMapSettings:: rotation() const
The rotation of the resulting map image, in degrees clockwise.
Map canvas rotation support is not implemented, 0 is used
Q_INVOKABLE QgsPoint QgsQuickMapSettings:: screenToCoordinate(const QPointF& point) const
Convert a screen coordinate to a map coordinate.
| Parameters | |
|---|---|
| point | A coordinate in pixel / screen coordinates |
| Returns | A coordinate in map coordinates |
void QgsQuickMapSettings:: setExtent(const QgsRectangle& extent)
Set coordinates of the rectangle which should be rendered.
The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use visibleExtent() to get the resulting extent.
void QgsQuickMapSettings:: setLayers(const QList<QgsMapLayer*>& layers)
Set list of layers for map rendering.
The layers must be registered in QgsProject. The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
void QgsQuickMapSettings:: setProject(QgsProject* project)
A project property should be used as a primary source of project all other components in the application.
QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::
When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.
void QgsQuickMapSettings:: setRotation(double rotation)
The rotation of the resulting map image, in degrees clockwise.
Map canvas rotation support is not implemented, 0 is used
void QgsQuickMapSettings:: setTransformContext(const QgsCoordinateTransformContext& context)
Sets the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
Q_INVOKABLE QgsCoordinateTransformContext QgsQuickMapSettings:: transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
void QgsQuickMapSettings:: destinationCrsChanged() signal
CRS of destination coordinate reference system.
Automatically loaded from project on QgsProject::
void QgsQuickMapSettings:: extentChanged() signal
Geographical coordinates of the rectangle that should be rendered.
The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use QgsQuickMapSettings::
Automatically loaded from project on QgsProject::
void QgsQuickMapSettings:: layersChanged() signal
Set list of layers for map rendering.
The layers must be registered in QgsProject. The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
Not loaded automatically from the associated project
void QgsQuickMapSettings:: outputDpiChanged() signal
Output DPI used for conversion between real world units (e.g.
mm) and pixels
Automatically loaded from project on QgsProject::
void QgsQuickMapSettings:: outputSizeChanged() signal
The size of the resulting map image.
Automatically loaded from project on QgsProject::
void QgsQuickMapSettings:: projectChanged() signal
A project property should be used as a primary source of project all other components in the application.
QgsProject should be attached to QgsQuickMapSettings before it is read (QgsProject::
When project is read, map settings (CRS, extent, ...) are automatically set from its DOM.
void QgsQuickMapSettings:: rotationChanged() signal
The rotation of the resulting map image, in degrees clockwise.
Map canvas rotation support is not implemented, 0 is used