diff options
author | Ian Chen <ian.1.chen@nokia.com> | 2012-05-14 10:26:59 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-17 03:03:13 +0200 |
commit | 993185661cf1e1a012a41382fdbfa76ee2edf16a (patch) | |
tree | 060a8d2d5bae0f8985d33077fd15811cad321576 /src | |
parent | f9377591312f3c426e8d4bfa45f7554ad7e3e966 (diff) | |
download | qtlocation-993185661cf1e1a012a41382fdbfa76ee2edf16a.tar.gz |
Fix map panning across dateline
Now handles wrapping and clipping during panning
Task-number: QTBUG-25658
Change-Id: I41e938134d1f57ffb75a942d55fc79d5e7565be4
Reviewed-by: Thomas Lowe <thomas.lowe@nokia.com>
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/location/qdeclarativegeomapgesturearea.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp index 56a94454..6ffee2b8 100644 --- a/src/imports/location/qdeclarativegeomapgesturearea.cpp +++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp @@ -812,6 +812,8 @@ void QDeclarativeGeoMapGestureArea::clearTouchData() velocityX_ = 0; velocityY_ = 0; pressTime_.start(); + sceneCenter_.setX(0); + sceneCenter_.setY(0); touchCenterCoord_.setLongitude(0); touchCenterCoord_.setLatitude(0); startCoord_.setLongitude(0); @@ -884,6 +886,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine() if (touchPoints_.count() == 0) { touchPointState_ = touchPoints0; } else if (touchPoints_.count() == 2) { + touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false); startTwoTouchPoints(); touchPointState_ = touchPoints2; } @@ -892,6 +895,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine() if (touchPoints_.count() == 0) { touchPointState_ = touchPoints0; } else if (touchPoints_.count() == 1) { + touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false); startOneTouchPoint(); touchPointState_ = touchPoints1; } @@ -916,8 +920,6 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine() */ void QDeclarativeGeoMapGestureArea::startOneTouchPoint() { - sceneCenter_ = QPointF(); - sceneStartPoint1_ = touchPoints_.at(0).scenePos(); lastPos_ = sceneStartPoint1_; lastPosTime_.start(); @@ -935,8 +937,6 @@ void QDeclarativeGeoMapGestureArea::startOneTouchPoint() void QDeclarativeGeoMapGestureArea::updateOneTouchPoint() { sceneCenter_ = touchPoints_.at(0).scenePos(); - touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false); - updateVelocityList(sceneCenter_); } @@ -946,8 +946,6 @@ void QDeclarativeGeoMapGestureArea::updateOneTouchPoint() */ void QDeclarativeGeoMapGestureArea::startTwoTouchPoints() { - sceneCenter_ = QPointF(); - sceneStartPoint1_ = touchPoints_.at(0).scenePos(); sceneStartPoint2_ = touchPoints_.at(1).scenePos(); QPointF startPos = (sceneStartPoint1_ + sceneStartPoint2_) * 0.5; @@ -971,7 +969,6 @@ void QDeclarativeGeoMapGestureArea::updateTwoTouchPoints() qreal dy = p1.y() - p2.y(); distanceBetweenTouchPoints_ = sqrt(dx * dx + dy * dy); sceneCenter_ = (p1 + p2) / 2; - touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false); updateVelocityList(sceneCenter_); @@ -1244,11 +1241,16 @@ bool QDeclarativeGeoMapGestureArea::canStartPan() */ void QDeclarativeGeoMapGestureArea::updatePan() { - QDeclarativeCoordinate *center = declarativeMap_->center(); - qreal newLat = center->latitude() + startCoord_.latitude() - touchCenterCoord_.latitude(); - qreal newLong = center->longitude() + startCoord_.longitude() - touchCenterCoord_.longitude(); - center->setLatitude(newLat); - center->setLongitude(newLong); + QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false); + int dx = static_cast<int>(sceneCenter_.x() - startPoint.x()); + int dy = static_cast<int>(sceneCenter_.y() - startPoint.y()); + QPointF mapCenterPoint; + mapCenterPoint.setY(map_->height() / 2.0 - dy); + mapCenterPoint.setX(map_->width() / 2.0 - dx); + AnimatableCoordinate animationStartCoordinate; + animationStartCoordinate.setCoordinate(map_->screenPositionToCoordinate(mapCenterPoint, false)); + map_->mapController()->setCenter(animationStartCoordinate); + } /*! |