From 38d9759198920037618c9ded08191bde83815f84 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 25 Jul 2017 18:34:24 +0300 Subject: 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 --- mobile-widgets/qml/MapWidget.qml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'mobile-widgets/qml') 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 -- cgit v1.2.3-70-g09d2