[Qt] Fix panning the map not updating the center property
This commit is contained in:
@@ -51,7 +51,6 @@ public:
|
||||
void setZoomLevel(qreal zoomLevel);
|
||||
qreal zoomLevel() const;
|
||||
|
||||
void setCenter(const QGeoCoordinate ¢er);
|
||||
QGeoCoordinate center() const;
|
||||
|
||||
QGeoServiceProvider::Error error() const;
|
||||
@@ -104,6 +103,9 @@ signals:
|
||||
void styleChanged();
|
||||
void bearingChanged(qreal angle);
|
||||
|
||||
public slots:
|
||||
void setCenter(const QGeoCoordinate ¢er);
|
||||
|
||||
private:
|
||||
qreal m_minimumZoomLevel = 0;
|
||||
qreal m_maximumZoomLevel = 20;
|
||||
|
||||
@@ -42,7 +42,11 @@ void QQuickMapboxGLRenderer::render()
|
||||
void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item)
|
||||
{
|
||||
if (!m_initialized) {
|
||||
QObject::connect(m_map.data(), SIGNAL(needsRendering()), item, SLOT(update()));
|
||||
auto qquickMapbox = static_cast<QQuickMapboxGL*>(item);
|
||||
|
||||
QObject::connect(m_map.data(), &QMapboxGL::needsRendering, qquickMapbox, &QQuickMapboxGL::update);
|
||||
QObject::connect(this, &QQuickMapboxGLRenderer::centerChanged, qquickMapbox, &QQuickMapboxGL::setCenter);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
@@ -64,6 +68,7 @@ void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item)
|
||||
|
||||
if (syncStatus & QQuickMapboxGL::PanNeedsSync) {
|
||||
m_map->moveBy(quickMap->swapPan());
|
||||
emit centerChanged(QGeoCoordinate(m_map->latitude(), m_map->longitude()));
|
||||
}
|
||||
|
||||
if (syncStatus & QQuickMapboxGL::BearingNeedsSync) {
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
#ifndef QQUICKMAPBOXGLRENDERER_H
|
||||
#define QQUICKMAPBOXGLRENDERER_H
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QObject>
|
||||
#include <QQuickFramebufferObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QGeoCoordinate;
|
||||
class QMapboxGL;
|
||||
class QOpenGLFramebufferObject;
|
||||
class QSize;
|
||||
class QMapboxGL;
|
||||
|
||||
class QQuickMapboxGLRenderer : public QQuickFramebufferObject::Renderer
|
||||
class QQuickMapboxGLRenderer : public QObject, public QQuickFramebufferObject::Renderer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QQuickMapboxGLRenderer();
|
||||
virtual ~QQuickMapboxGLRenderer();
|
||||
@@ -19,6 +23,9 @@ public:
|
||||
virtual void render();
|
||||
virtual void synchronize(QQuickFramebufferObject *item);
|
||||
|
||||
signals:
|
||||
void centerChanged(const QGeoCoordinate &coordinate);
|
||||
|
||||
private:
|
||||
bool m_initialized = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user