diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-08-07 02:13:25 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-08-07 00:51:21 -0700 |
commit | 0fc9a3bf4ae532f5a9afd6d3fd8731eb16745671 (patch) | |
tree | a24b30f6acc5a8746780b03ed666447d2a745f32 /mobile-widgets | |
parent | d421660f91d56ac434860a1deff17eeeacbc7e26 (diff) | |
download | subsurface-0fc9a3bf4ae532f5a9afd6d3fd8731eb16745671.tar.gz |
mapwidget.qml: add a couple of helpers
Add stopZoomAnimations(), which is really just a precaution
function to make sure we have stopped all animation of the
map before doing calculations! Since the animation *should*
be running in a separate thread, this would make sure the Map "center"
and "zoomLevel" properties do not change.
Add pointIsVisible(), which is a helper to determine
if a point created by map.fromCoordinate() method is inside
the viewport. fromCoordinate() has to be called without the
"false" (clip) flag for this to work.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/MapWidget.qml | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 42bc546ce..cdfa25d79 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -148,7 +148,17 @@ Item { mapAnimationZoomOut.restart() } + function pointIsVisible(pt) { + return !isNaN(pt.x) + } + + function stopZoomAnimations() { + mapAnimationZoomIn.stop() + mapAnimationZoomOut.stop() + } + function centerOnCoordinate(coord) { + stopZoomAnimations() newCenter = coord if (coord.latitude === 0.0 && coord.longitude === 0.0) { newZoom = 2.6 @@ -157,8 +167,8 @@ Item { var zoomStored = zoomLevel newZoomOut = zoomLevel while (zoomLevel > minimumZoomLevel) { - var pt = fromCoordinate(coord, false) - if (pt.x > 0 && pt.y > 0 && pt.x < width && pt.y < height) { + var pt = fromCoordinate(coord) + if (pointIsVisible(pt)) { newZoomOut = zoomLevel break } |