summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap.cpp65
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap_p.h6
2 files changed, 48 insertions, 23 deletions
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
index bfb959e4..b46db2c1 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
@@ -47,6 +47,7 @@
#include <Qt3D/qglview.h>
#include <Qt3D/qglsubsurface.h>
#include <QtCore/QCoreApplication>
+#include <QtCore/qnumeric.h>
#include <QThread>
#include "tilecache.h"
@@ -76,7 +77,7 @@
QT_BEGIN_NAMESPACE
/*!
- \qmlclass Map3D
+ \qmlclass Map
\brief The Map element displays a map.
\inherits QDeclarativeItem
@@ -681,9 +682,10 @@ qreal QDeclarative3DGraphicsGeoMap::zoomLevel() const
*/
void QDeclarative3DGraphicsGeoMap::setCenter(QDeclarativeCoordinate *center)
{
- if (center_) {
+ if (center == center_)
+ return;
+ if (center_)
center_->disconnect(this);
- }
center_ = center;
if (center_) {
connect(center_,
@@ -698,37 +700,60 @@ void QDeclarative3DGraphicsGeoMap::setCenter(QDeclarativeCoordinate *center)
SIGNAL(altitudeChanged(double)),
this,
SLOT(centerAltitudeChanged(double)));
-
-// if (mapData_) {
-// mapData_->setCenter(center_->coordinate());
-// }
+ if (center_->coordinate().isValid()) {
+ CameraData cameraData = map_->cameraData();
+ cameraData.setCenter(center_->coordinate());
+ map_->setCameraData(cameraData);
+ update();
+ }
}
- emit declarativeCenterChanged(center_);
+ emit centerChanged(center_);
}
QDeclarativeCoordinate* QDeclarative3DGraphicsGeoMap::center()
{
-// if (mapData_ && center_)
-// center_->setCoordinate(mapData_->center());
+ if (!center_)
+ return new QDeclarativeCoordinate(map_->cameraData().center());
return center_;
}
-void QDeclarative3DGraphicsGeoMap::centerLatitudeChanged(double /*latitude*/)
+void QDeclarative3DGraphicsGeoMap::centerLatitudeChanged(double latitude)
{
-// if (mapData_ && center_)
-// mapData_->setCenter(center_->coordinate());
+ if (qIsNaN(latitude))
+ return;
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLatitude(latitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ emit centerChanged(center_);
}
-void QDeclarative3DGraphicsGeoMap::centerLongitudeChanged(double /*longitude*/)
+void QDeclarative3DGraphicsGeoMap::centerLongitudeChanged(double longitude)
{
-// if (mapData_ && center_)
-// mapData_->setCenter(center_->coordinate());
+ if (qIsNaN(longitude))
+ return;
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLongitude(longitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ emit centerChanged(center_);
}
-void QDeclarative3DGraphicsGeoMap::centerAltitudeChanged(double /*altitude*/)
+void QDeclarative3DGraphicsGeoMap::centerAltitudeChanged(double altitude)
{
-// if (mapData_ && center_)
-// mapData_->setCenter(center_->coordinate());
+ if (qIsNaN(altitude))
+ return;
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setAltitude(altitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ emit centerChanged(center_);
}
/*!
@@ -1145,7 +1170,7 @@ void QDeclarative3DGraphicsGeoMap::hoverLeaveEvent(QHoverEvent *event)
void QDeclarative3DGraphicsGeoMap::internalCenterChanged(const QGeoCoordinate &coordinate)
{
- emit declarativeCenterChanged(new QDeclarativeCoordinate(coordinate, this));
+ emit centerChanged(new QDeclarativeCoordinate(coordinate, this));
}
//void QDeclarative3DGraphicsGeoMap::internalMapTypeChanged(QGraphicsGeoMap::MapType mapType)
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
index b0b0c3d4..64f9489b 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
@@ -55,7 +55,7 @@
#include "qdeclarativegeomapflickable_p.h"
#include "qdeclarativegeomappincharea_p.h"
-#define QT_DECLARATIVE_LOCATION_TRACE 1
+//#define QT_DECLARATIVE_LOCATION_TRACE 1
#ifdef QT_DECLARATIVE_LOCATION_TRACE
#define QLOC_TRACE0 qDebug() << __FILE__ << __FUNCTION__;
@@ -103,7 +103,7 @@ class QDeclarative3DGraphicsGeoMap : public QSGPaintedItem
Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel CONSTANT)
Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
// Q_PROPERTY(MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
- Q_PROPERTY(QDeclarativeCoordinate* center READ center WRITE setCenter NOTIFY declarativeCenterChanged)
+ Q_PROPERTY(QDeclarativeCoordinate* center READ center WRITE setCenter NOTIFY centerChanged)
// Q_PROPERTY(ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
Q_INTERFACES(QDeclarativeParserStatus)
@@ -207,7 +207,7 @@ Q_SIGNALS:
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
void sizeChanged(const QSizeF &size);
void zoomLevelChanged(qreal zoomLevel);
- void declarativeCenterChanged(const QDeclarativeCoordinate *coordinate);
+ void centerChanged(const QDeclarativeCoordinate *coordinate);
// void mapTypeChanged(QDeclarative3DGraphicsGeoMap::MapType mapType);
// void connectivityModeChanged(QDeclarative3DGraphicsGeoMap::ConnectivityMode connectivityMode);