diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-07-25 18:34:24 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-28 07:31:11 -0700 |
commit | 38d9759198920037618c9ded08191bde83815f84 (patch) | |
tree | 152dbf2c4d5122085c93fda02ea55b3143274027 /mobile-widgets | |
parent | f1020a02ce3c17cfce52e55cb4e043fbfa0d76cb (diff) | |
download | subsurface-38d9759198920037618c9ded08191bde83815f84.tar.gz |
mapwidget.qml: add double click on zoom
Double clicking a marker or the newly added MouseArea now performs
a +2 zoom-in over a period of 500ms and centers on that clicked
coordinate.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/MapWidget.qml | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index a8eb7550e..0f0bca05e 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -31,8 +31,10 @@ Item { readonly property var defaultCenter: QtPositioning.coordinate(0, 0) readonly property var defaultZoomIn: 17.0 readonly property var defaultZoomOut: 1.0 + readonly property var zoomStep: 2.0 property var newCenter: defaultCenter property var newZoom: 1.0 + property var clickCoord: QtPositioning.coordinate(0, 0); Component.onCompleted: { activeMapType = mapType.SATELLITE @@ -65,10 +67,8 @@ Item { MouseArea { anchors.fill: parent - onClicked: { - mapHelper.model.setSelectedUuid(model.uuid, true) - mapItemImageAnimation.restart() - } + onClicked: mapHelper.model.setSelectedUuid(model.uuid, true) + onDoubleClicked: map.doubleClickHandler(model.coordinate) } } } @@ -96,6 +96,27 @@ Item { } } + ParallelAnimation { + id: mapAnimationClick + CoordinateAnimation { + target: map; property: "center"; to: map.newCenter; duration: 500 + } + NumberAnimation { + target: map; property: "zoomLevel"; to: map.newZoom; duration: 500 + } + } + + MouseArea { + anchors.fill: parent + onDoubleClicked: map.doubleClickHandler(map.toCoordinate(Qt.point(mouseX, mouseY))) + } + + function doubleClickHandler(coord) { + newCenter = coord + newZoom = zoomLevel + zoomStep + mapAnimationClick.restart() + } + function animateMapZoomIn(coord) { zoomLevel = defaultZoomOut newCenter = coord |