[Qt] Fix panning the map not updating the center property

This commit is contained in:
Thiago Marcos P. Santos
2016-05-02 21:36:03 +03:00
parent d4070d3356
commit 7aa0a88c64
3 changed files with 19 additions and 5 deletions

View File

@@ -51,7 +51,6 @@ public:
void setZoomLevel(qreal zoomLevel);
qreal zoomLevel() const;
void setCenter(const QGeoCoordinate &center);
QGeoCoordinate center() const;
QGeoServiceProvider::Error error() const;
@@ -104,6 +103,9 @@ signals:
void styleChanged();
void bearingChanged(qreal angle);
public slots:
void setCenter(const QGeoCoordinate &center);
private:
qreal m_minimumZoomLevel = 0;
qreal m_maximumZoomLevel = 20;

View File

@@ -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) {

View File

@@ -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;