Qt World Summit: Register Today!

How to combine Map and MouseArea

  • Hi!
    I use this code: https://stackoverflow.com/questions/49344638/adding-markers-places-to-qt-qml-maps
    If I add MouseArea, I can't move the map. Please tell me how to move the card and receive a signal from MouseArea?

  • It's works:

            Map {
                    id: mapview
                    anchors.fill: parent
                    plugin: plugin
                    center: QtPositioning.coordinate(59.91, 10.75)
                    zoomLevel: 14
                        model: markerModel
                        delegate: mapcomponent
                    MouseArea {
                        anchors.fill: parent
                        onPressAndHold:  {
                            var coordinate = mapview.toCoordinate(Qt.point(mouse.x,mouse.y))
            Component {
                    id: mapcomponent
                    MapQuickItem {
                        id: marker
                        anchorPoint.x: image.width/4
                        anchorPoint.y: image.height
                        coordinate: position
                        sourceItem: Image {
                            id: image
                            source: "qrc:/Images/Images/markerRed.png"

Log in to reply