diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-06-18 12:26:00 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-06-30 13:13:38 +0000 |
commit | 10fb5986fee916f70e2ab0b9d250a38cc747843b (patch) | |
tree | fe7a485a2d1a5e0398bd7b23274c11dca652080b | |
parent | af821cdc792bb0057c920f264bcb564988e0ff88 (diff) | |
download | qtlocation-10fb5986fee916f70e2ab0b9d250a38cc747843b.tar.gz |
Fix map flick bounces back on zoomlevel 2
Use different type of the coordinate's interpolator when
flicking west and east to prevent longitude bounce effect.
Add checks for valid latitude before starting a flick animation
to prevent latitude bounce effect.
Task-number: QTBUG-44311
Change-Id: I1f4d81f299759b130f4e08ccf8b2baa7e5105459
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r-- | src/imports/location/qdeclarativegeomapgesturearea.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp index 9629e5e1..5a74d231 100644 --- a/src/imports/location/qdeclarativegeomapgesturearea.cpp +++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp @@ -1164,8 +1164,25 @@ void QDeclarativeGeoMapGestureArea::startFlick(int dx, int dy, int timeMs) pan_.animation_->stop(); QGeoCoordinate animationEndCoordinate = map_->mapController()->center(); pan_.animation_->setDuration(timeMs); - animationEndCoordinate.setLongitude(animationStartCoordinate.longitude() - (dx / pow(2.0, map_->mapController()->zoom()))); - animationEndCoordinate.setLatitude(animationStartCoordinate.latitude() + (dy / pow(2.0, map_->mapController()->zoom()))); + + double zoom = pow(2.0, map_->mapController()->zoom()); + double longitude = animationStartCoordinate.longitude() - (dx / zoom); + double latitude = animationStartCoordinate.latitude() + (dy / zoom); + + if (dx > 0) + pan_.animation_->setDirection(QQuickGeoCoordinateAnimation::East); + else + pan_.animation_->setDirection(QQuickGeoCoordinateAnimation::West); + + //keep animation in correct bounds + if (latitude > 85.05113) + latitude = 85.05113; + else if (latitude < -85.05113) + latitude = -85.05113; + + animationEndCoordinate.setLongitude(longitude); + animationEndCoordinate.setLatitude(latitude); + pan_.animation_->setFrom(animationStartCoordinate); pan_.animation_->setTo(animationEndCoordinate); pan_.animation_->start(); |