Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Qt Location QML : How to enable MapGestureArea ?

[SOLVED] Qt Location QML : How to enable MapGestureArea ?

Scheduled Pinned Locked Moved QML and Qt Quick
qt locationqmlmapgesturearea
3 Posts 1 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SylvainP
    wrote on 22 Jul 2015, 12:01 last edited by SylvainP
    #1

    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.html

    Plugin {
        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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SylvainP
      wrote on 23 Jul 2015, 11:50 last edited by SylvainP
      #2

      If someone is willing to try my code :
      https://github.com/GarthPS/poc_qtlocation_qml

      Thanks by advance!

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SylvainP
        wrote on 28 Jul 2015, 22:07 last edited by SylvainP
        #3

        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.

        1 Reply Last reply
        0

        1/3

        22 Jul 2015, 12:01

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved