[SOLVED] Qt Location QML : How to enable MapGestureArea ?
-
Hello
I am new to Qt Quick and I am missing something about using the Qt Quick location Map component.
I want to enable panning, flicking and pinch-to-zoom gestures but I can not found out how to do it.
The documentation gives 3 "different" examples:http://doc.qt.io/qt-5/qml-location5-maps.html
Map { id: map // Enable pan, flick, and pinch gestures to zoom in and out gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture gesture.flickDeceleration: 3000 gesture.enabled: true }
http://doc.qt.io/qt-5/qml-qtlocation-mapgesturearea.html
Map { gesture.enabled: true gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture }
and
http://doc.qt.io/qt-5/qml-qtlocation-map.htmlPlugin { id: somePlugin // code here to choose the plugin as necessary } Map { id: map plugin: somePlugin center { latitude: -27 longitude: 153 } zoomLevel: map.minimumZoomLevel gesture.enabled: true }
So I wrote this code which fails to enable gesture :
main.qml: #### import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Window 2.2 import QtPositioning 5.5 import QtLocation 5.5 ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 visible: true Plugin { id: myPlugin name: "osm" PluginParameter { name: "osm.mapping.host"; value: "http://c.tile.thunderforest.com/outdoors/" } } Map { property bool followme : false id : map plugin: myPlugin anchors.fill: parent focus: true zoomLevel: 9 gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture gesture.flickDeceleration: 3000 gesture.enabled: true } }
I tested this code under android and none of panning, flicking and pinch-to-zoom gestures works.
Thank you for your help.
-
If someone is willing to try my code :
https://github.com/GarthPS/poc_qtlocation_qmlThanks by advance!
-
I misunderstood meaning of flick gesture so I missed that it was a reported bug although I did a search(for mapgesture).
https://bugreports.qt.io/browse/QTBUG-46388
It is fixed in 5.6 but not 5.5.
However there is a simple workaround. You have to add a MouseArea to the Map element as shown below :Map { id : map plugin: myPlugin anchors.fill: parent focus: true zoomLevel: 9 gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture gesture.flickDeceleration: 3000 gesture.enabled: true //XXXXXXX Added MouseArea { anchors.fill: parent } //XXXXXXX }
Thanks to Alexander for pointing me this.