Skip to content

Commit

Permalink
[quick] Add a map settings center property return the current extent …
Browse files Browse the repository at this point in the history
…center point as QgsPoint
  • Loading branch information
nirvn authored and nyalldawson committed Sep 25, 2022
1 parent c6eca78 commit 75a79f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/quickgui/qgsquickmapsettings.cpp
Expand Up @@ -89,6 +89,11 @@ void QgsQuickMapSettings::setExtent( const QgsRectangle &extent )
emit extentChanged();
}

QgsPoint QgsQuickMapSettings::center() const
{
return QgsPoint( extent().center() );
}

void QgsQuickMapSettings::setCenter( const QgsPoint &center )
{
QgsVector delta = QgsPointXY( center ) - mMapSettings.extent().center();
Expand Down
8 changes: 8 additions & 0 deletions src/quickgui/qgsquickmapsettings.h
Expand Up @@ -57,6 +57,11 @@ class QUICK_EXPORT QgsQuickMapSettings : public QObject
*/
Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )

/**
* Geographical coordinate representing the center point of the current extent
*/
Q_PROPERTY( QgsPoint center READ center WRITE setCenter NOTIFY extentChanged )

/**
* Geographical coordinates of the rectangle that should be rendered.
* The actual visible extent used for rendering could be slightly different
Expand Down Expand Up @@ -137,6 +142,9 @@ class QUICK_EXPORT QgsQuickMapSettings : public QObject
//! \copydoc QgsQuickMapSettings::project
QgsProject *project() const;

//! Returns the center point of the current map extent
QgsPoint center() const;

//! Move current map extent to have center point defined by \a center
Q_INVOKABLE void setCenter( const QgsPoint &center );

Expand Down

0 comments on commit 75a79f6

Please sign in to comment.