mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
f1020a02ce
commit
38d9759198
1 changed files with 25 additions and 4 deletions
|
|
@ -31,8 +31,10 @@ Item {
|
||||||
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
||||||
readonly property var defaultZoomIn: 17.0
|
readonly property var defaultZoomIn: 17.0
|
||||||
readonly property var defaultZoomOut: 1.0
|
readonly property var defaultZoomOut: 1.0
|
||||||
|
readonly property var zoomStep: 2.0
|
||||||
property var newCenter: defaultCenter
|
property var newCenter: defaultCenter
|
||||||
property var newZoom: 1.0
|
property var newZoom: 1.0
|
||||||
|
property var clickCoord: QtPositioning.coordinate(0, 0);
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
activeMapType = mapType.SATELLITE
|
activeMapType = mapType.SATELLITE
|
||||||
|
|
@ -65,10 +67,8 @@ Item {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: mapHelper.model.setSelectedUuid(model.uuid, true)
|
||||||
mapHelper.model.setSelectedUuid(model.uuid, true)
|
onDoubleClicked: map.doubleClickHandler(model.coordinate)
|
||||||
mapItemImageAnimation.restart()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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) {
|
function animateMapZoomIn(coord) {
|
||||||
zoomLevel = defaultZoomOut
|
zoomLevel = defaultZoomOut
|
||||||
newCenter = coord
|
newCenter = coord
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue